Skip to content

Commit 9617c01

Browse files
authored
refactor(project): splits schema out into multiple files (#68)
1 parent bb5c2c6 commit 9617c01

File tree

11 files changed

+586
-563
lines changed

11 files changed

+586
-563
lines changed

lib/project/schema/_embed/schema.cue

Lines changed: 112 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,5 @@
11
package schema
22

3-
#TagStrategy: string
4-
#enumTagStrategy: #TagStrategyGitCommit
5-
#TagStrategyGitCommit: #TagStrategy & {
6-
"commit"
7-
}
8-
9-
// Blueprint contains the schema for blueprint files.
10-
#Blueprint: {
11-
// Version defines the version of the blueprint schema being used.
12-
version: =~"^\\d+\\.\\d+" @go(Version)
13-
14-
// Global contains the global configuration for the blueprint.
15-
// +optional
16-
global?: #Global @go(Global)
17-
18-
// Project contains the configuration for the project.
19-
// +optional
20-
project?: #Project @go(Project)
21-
}
22-
23-
// Deployment contains the configuration for the deployment of the project.
24-
#Deployment: {
25-
// Environment contains the environment to deploy the module to.
26-
environment: (_ | *"dev") & {
27-
string
28-
} @go(Environment)
29-
30-
// Modules contains the configuration for the deployment modules for the project.
31-
// +optional
32-
modules?: null | #DeploymentModules @go(Modules,*DeploymentModules)
33-
}
34-
35-
// Deployment contains the configuration for the deployment of the project.
36-
#DeploymentModules: {
37-
// Main contains the configuration for the main deployment module.
38-
main: #Module @go(Main)
39-
40-
// Support contains the configuration for the support deployment modules.
41-
// +optional
42-
support?: {
43-
[string]: #Module
44-
} @go(Support,map[string]Module)
45-
}
46-
47-
// Module contains the configuration for a deployment module.
48-
#Module: {
49-
// Container contains the name of the container holding the deployment code.
50-
// Defaults to <module_name>-deployment). For the main module, <module_name> is the project name.
51-
// +optional
52-
container?: null | string @go(Container,*string)
53-
54-
// Namespace contains the namespace to deploy the module to.
55-
namespace: (_ | *"default") & {
56-
string
57-
} @go(Namespace)
58-
59-
// Values contains the values to pass to the deployment module.
60-
values: _ @go(Values,any)
61-
62-
// Version contains the version of the deployment module.
63-
version: string @go(Version)
64-
}
65-
663
// Global contains the global configuration for the blueprint.
674
#Global: {
685
// CI contains the configuration for the CI system.
@@ -117,32 +54,6 @@ package schema
11754
url: string @go(Url)
11855
}
11956

120-
// Project contains the configuration for the project.
121-
#Project: {
122-
// Name contains the name of the project.
123-
name: =~"^[a-z][a-z0-9_-]*$" @go(Name)
124-
125-
// Container is the name that the container will be built as.
126-
container: (_ | *name) & {
127-
string
128-
} @go(Container)
129-
130-
// CI contains the configuration for the CI system.
131-
// +optional
132-
ci?: #ProjectCI @go(CI)
133-
134-
// Deployment contains the configuration for the deployment of the project.
135-
// +optional
136-
deployment?: #Deployment @go(Deployment)
137-
}
138-
#ProjectCI: {
139-
// Targets configures the individual targets that are run by the CI system.
140-
// +optional
141-
targets?: {
142-
[string]: #Target
143-
} @go(Targets,map[string]Target)
144-
}
145-
14657
// Providers contains the configuration for the providers being used by the CI system.
14758
#Providers: {
14859
// AWS contains the configuration for the AWS provider.
@@ -210,43 +121,95 @@ package schema
210121
// +optional
211122
credentials?: null | #Secret @go(Credentials,*Secret)
212123
}
124+
#TagStrategy: string
125+
#enumTagStrategy: #TagStrategyGitCommit
126+
#TagStrategyGitCommit: #TagStrategy & {
127+
"commit"
128+
}
213129

214-
// ProviderGithub contains the configuration for the Github provider.
215-
#ProviderGithub: {
216-
// Credentials contains the credentials to use for Github
217-
// +optional
218-
credentials?: #Secret @go(Credentials)
130+
// Blueprint contains the schema for blueprint files.
131+
#Blueprint: {
132+
// Version defines the version of the blueprint schema being used.
133+
version: =~"^\\d+\\.\\d+" @go(Version)
219134

220-
// Registry contains the Github registry to use.
135+
// Global contains the global configuration for the blueprint.
221136
// +optional
222-
registry?: null | string @go(Registry,*string)
137+
global?: #Global @go(Global)
138+
139+
// Project contains the configuration for the project.
140+
// +optional
141+
project?: #Project @go(Project)
223142
}
224143

225-
// Secret contains the secret provider and a list of mappings
226-
#Secret: {
227-
// Maps contains mappings for Earthly secret names to JSON keys in the secret.
228-
// Mutually exclusive with Name.
144+
// Deployment contains the configuration for the deployment of the project.
145+
#Deployment: {
146+
// Environment contains the environment to deploy the module to.
147+
environment: (_ | *"dev") & {
148+
string
149+
} @go(Environment)
150+
151+
// Modules contains the configuration for the deployment modules for the project.
229152
// +optional
230-
maps?: {
231-
[string]: string
232-
} @go(Maps,map[string]string)
153+
modules?: null | #DeploymentModules @go(Modules,*DeploymentModules)
154+
}
233155

234-
// Name contains the name of the Earthly secret to use.
235-
// Mutually exclusive with Maps.
156+
// Deployment contains the configuration for the deployment of the project.
157+
#DeploymentModules: {
158+
// Main contains the configuration for the main deployment module.
159+
main: #Module @go(Main)
160+
161+
// Support contains the configuration for the support deployment modules.
236162
// +optional
237-
name?: null | string @go(Name,*string)
163+
support?: {
164+
[string]: #Module
165+
} @go(Support,map[string]Module)
166+
}
167+
version: "1.0"
238168

239-
// Optional determines if the secret is optional.
169+
// Module contains the configuration for a deployment module.
170+
#Module: {
171+
// Container contains the name of the container holding the deployment code.
172+
// Defaults to <module_name>-deployment). For the main module, <module_name> is the project name.
240173
// +optional
241-
optional?: null | bool @go(Optional,*bool)
174+
container?: null | string @go(Container,*string)
242175

243-
// Path contains the path to the secret.
244-
path: string @go(Path)
176+
// Namespace contains the namespace to deploy the module to.
177+
namespace: (_ | *"default") & {
178+
string
179+
} @go(Namespace)
245180

246-
// Provider contains the provider to use for the secret.
247-
provider: string @go(Provider)
181+
// Values contains the values to pass to the deployment module.
182+
values: _ @go(Values,any)
183+
184+
// Version contains the version of the deployment module.
185+
version: string @go(Version)
186+
}
187+
188+
// Project contains the configuration for the project.
189+
#Project: {
190+
// Name contains the name of the project.
191+
name: =~"^[a-z][a-z0-9_-]*$" @go(Name)
192+
193+
// Container is the name that the container will be built as.
194+
container: (_ | *name) & {
195+
string
196+
} @go(Container)
197+
198+
// CI contains the configuration for the CI system.
199+
// +optional
200+
ci?: #ProjectCI @go(CI)
201+
202+
// Deployment contains the configuration for the deployment of the project.
203+
// +optional
204+
deployment?: #Deployment @go(Deployment)
205+
}
206+
#ProjectCI: {
207+
// Targets configures the individual targets that are run by the CI system.
208+
// +optional
209+
targets?: {
210+
[string]: #Target
211+
} @go(Targets,map[string]Target)
248212
}
249-
version: "1.0"
250213
#Tagging: {
251214
// Aliases contains the aliases to use for git tags.
252215
// +optional
@@ -284,3 +247,39 @@ version: "1.0"
284247
// +optional
285248
secrets?: [...#Secret] @go(Secrets,[]Secret)
286249
}
250+
251+
// ProviderGithub contains the configuration for the Github provider.
252+
#ProviderGithub: {
253+
// Credentials contains the credentials to use for Github
254+
// +optional
255+
credentials?: #Secret @go(Credentials)
256+
257+
// Registry contains the Github registry to use.
258+
// +optional
259+
registry?: null | string @go(Registry,*string)
260+
}
261+
262+
// Secret contains the secret provider and a list of mappings
263+
#Secret: {
264+
// Maps contains mappings for Earthly secret names to JSON keys in the secret.
265+
// Mutually exclusive with Name.
266+
// +optional
267+
maps?: {
268+
[string]: string
269+
} @go(Maps,map[string]string)
270+
271+
// Name contains the name of the Earthly secret to use.
272+
// Mutually exclusive with Maps.
273+
// +optional
274+
name?: null | string @go(Name,*string)
275+
276+
// Optional determines if the secret is optional.
277+
// +optional
278+
optional?: null | bool @go(Optional,*bool)
279+
280+
// Path contains the path to the secret.
281+
path: string @go(Path)
282+
283+
// Provider contains the provider to use for the secret.
284+
provider: string @go(Provider)
285+
}

lib/project/schema/deployment.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package schema
2+
3+
// Deployment contains the configuration for the deployment of the project.
4+
type Deployment struct {
5+
// Environment contains the environment to deploy the module to.
6+
Environment string `json:"environment"`
7+
8+
// Modules contains the configuration for the deployment modules for the project.
9+
// +optional
10+
Modules *DeploymentModules `json:"modules"`
11+
}
12+
13+
// Deployment contains the configuration for the deployment of the project.
14+
type DeploymentModules struct {
15+
// Main contains the configuration for the main deployment module.
16+
Main Module `json:"main"`
17+
18+
// Support contains the configuration for the support deployment modules.
19+
// +optional
20+
Support map[string]Module `json:"support"`
21+
}
22+
23+
// Module contains the configuration for a deployment module.
24+
type Module struct {
25+
// Container contains the name of the container holding the deployment code.
26+
// Defaults to <module_name>-deployment). For the main module, <module_name> is the project name.
27+
// +optional
28+
Container *string `json:"container"`
29+
30+
// Namespace contains the namespace to deploy the module to.
31+
Namespace string `json:"namespace"`
32+
33+
// Values contains the values to pass to the deployment module.
34+
Values any `json:"values"`
35+
36+
// Version contains the version of the deployment module.
37+
Version string `json:"version"`
38+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// Code generated by cue get go. DO NOT EDIT.
2+
3+
//cue:generate cue get go github.com/input-output-hk/catalyst-forge/lib/project/schema
4+
5+
package schema
6+
7+
// Deployment contains the configuration for the deployment of the project.
8+
#Deployment: {
9+
// Environment contains the environment to deploy the module to.
10+
environment: string @go(Environment)
11+
12+
// Modules contains the configuration for the deployment modules for the project.
13+
// +optional
14+
modules?: null | #DeploymentModules @go(Modules,*DeploymentModules)
15+
}
16+
17+
// Deployment contains the configuration for the deployment of the project.
18+
#DeploymentModules: {
19+
// Main contains the configuration for the main deployment module.
20+
main: #Module @go(Main)
21+
22+
// Support contains the configuration for the support deployment modules.
23+
// +optional
24+
support?: {[string]: #Module} @go(Support,map[string]Module)
25+
}
26+
27+
// Module contains the configuration for a deployment module.
28+
#Module: {
29+
// Container contains the name of the container holding the deployment code.
30+
// Defaults to <module_name>-deployment). For the main module, <module_name> is the project name.
31+
// +optional
32+
container?: null | string @go(Container,*string)
33+
34+
// Namespace contains the namespace to deploy the module to.
35+
namespace: string @go(Namespace)
36+
37+
// Values contains the values to pass to the deployment module.
38+
values: _ @go(Values,any)
39+
40+
// Version contains the version of the deployment module.
41+
version: string @go(Version)
42+
}

0 commit comments

Comments
 (0)