Skip to content

Commit

Permalink
refactor(project): splits schema out into multiple files (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmgilman authored Oct 8, 2024
1 parent bb5c2c6 commit 9617c01
Show file tree
Hide file tree
Showing 11 changed files with 586 additions and 563 deletions.
225 changes: 112 additions & 113 deletions lib/project/schema/_embed/schema.cue
Original file line number Diff line number Diff line change
@@ -1,68 +1,5 @@
package schema

#TagStrategy: string
#enumTagStrategy: #TagStrategyGitCommit
#TagStrategyGitCommit: #TagStrategy & {
"commit"
}

// Blueprint contains the schema for blueprint files.
#Blueprint: {
// Version defines the version of the blueprint schema being used.
version: =~"^\\d+\\.\\d+" @go(Version)

// Global contains the global configuration for the blueprint.
// +optional
global?: #Global @go(Global)

// Project contains the configuration for the project.
// +optional
project?: #Project @go(Project)
}

// Deployment contains the configuration for the deployment of the project.
#Deployment: {
// Environment contains the environment to deploy the module to.
environment: (_ | *"dev") & {
string
} @go(Environment)

// Modules contains the configuration for the deployment modules for the project.
// +optional
modules?: null | #DeploymentModules @go(Modules,*DeploymentModules)
}

// Deployment contains the configuration for the deployment of the project.
#DeploymentModules: {
// Main contains the configuration for the main deployment module.
main: #Module @go(Main)

// Support contains the configuration for the support deployment modules.
// +optional
support?: {
[string]: #Module
} @go(Support,map[string]Module)
}

// Module contains the configuration for a deployment module.
#Module: {
// Container contains the name of the container holding the deployment code.
// Defaults to <module_name>-deployment). For the main module, <module_name> is the project name.
// +optional
container?: null | string @go(Container,*string)

// Namespace contains the namespace to deploy the module to.
namespace: (_ | *"default") & {
string
} @go(Namespace)

// Values contains the values to pass to the deployment module.
values: _ @go(Values,any)

// Version contains the version of the deployment module.
version: string @go(Version)
}

// Global contains the global configuration for the blueprint.
#Global: {
// CI contains the configuration for the CI system.
Expand Down Expand Up @@ -117,32 +54,6 @@ package schema
url: string @go(Url)
}

// Project contains the configuration for the project.
#Project: {
// Name contains the name of the project.
name: =~"^[a-z][a-z0-9_-]*$" @go(Name)

// Container is the name that the container will be built as.
container: (_ | *name) & {
string
} @go(Container)

// CI contains the configuration for the CI system.
// +optional
ci?: #ProjectCI @go(CI)

// Deployment contains the configuration for the deployment of the project.
// +optional
deployment?: #Deployment @go(Deployment)
}
#ProjectCI: {
// Targets configures the individual targets that are run by the CI system.
// +optional
targets?: {
[string]: #Target
} @go(Targets,map[string]Target)
}

// Providers contains the configuration for the providers being used by the CI system.
#Providers: {
// AWS contains the configuration for the AWS provider.
Expand Down Expand Up @@ -210,43 +121,95 @@ package schema
// +optional
credentials?: null | #Secret @go(Credentials,*Secret)
}
#TagStrategy: string
#enumTagStrategy: #TagStrategyGitCommit
#TagStrategyGitCommit: #TagStrategy & {
"commit"
}

// ProviderGithub contains the configuration for the Github provider.
#ProviderGithub: {
// Credentials contains the credentials to use for Github
// +optional
credentials?: #Secret @go(Credentials)
// Blueprint contains the schema for blueprint files.
#Blueprint: {
// Version defines the version of the blueprint schema being used.
version: =~"^\\d+\\.\\d+" @go(Version)

// Registry contains the Github registry to use.
// Global contains the global configuration for the blueprint.
// +optional
registry?: null | string @go(Registry,*string)
global?: #Global @go(Global)

// Project contains the configuration for the project.
// +optional
project?: #Project @go(Project)
}

// Secret contains the secret provider and a list of mappings
#Secret: {
// Maps contains mappings for Earthly secret names to JSON keys in the secret.
// Mutually exclusive with Name.
// Deployment contains the configuration for the deployment of the project.
#Deployment: {
// Environment contains the environment to deploy the module to.
environment: (_ | *"dev") & {
string
} @go(Environment)

// Modules contains the configuration for the deployment modules for the project.
// +optional
maps?: {
[string]: string
} @go(Maps,map[string]string)
modules?: null | #DeploymentModules @go(Modules,*DeploymentModules)
}

// Name contains the name of the Earthly secret to use.
// Mutually exclusive with Maps.
// Deployment contains the configuration for the deployment of the project.
#DeploymentModules: {
// Main contains the configuration for the main deployment module.
main: #Module @go(Main)

// Support contains the configuration for the support deployment modules.
// +optional
name?: null | string @go(Name,*string)
support?: {
[string]: #Module
} @go(Support,map[string]Module)
}
version: "1.0"

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

// Path contains the path to the secret.
path: string @go(Path)
// Namespace contains the namespace to deploy the module to.
namespace: (_ | *"default") & {
string
} @go(Namespace)

// Provider contains the provider to use for the secret.
provider: string @go(Provider)
// Values contains the values to pass to the deployment module.
values: _ @go(Values,any)

// Version contains the version of the deployment module.
version: string @go(Version)
}

// Project contains the configuration for the project.
#Project: {
// Name contains the name of the project.
name: =~"^[a-z][a-z0-9_-]*$" @go(Name)

// Container is the name that the container will be built as.
container: (_ | *name) & {
string
} @go(Container)

// CI contains the configuration for the CI system.
// +optional
ci?: #ProjectCI @go(CI)

// Deployment contains the configuration for the deployment of the project.
// +optional
deployment?: #Deployment @go(Deployment)
}
#ProjectCI: {
// Targets configures the individual targets that are run by the CI system.
// +optional
targets?: {
[string]: #Target
} @go(Targets,map[string]Target)
}
version: "1.0"
#Tagging: {
// Aliases contains the aliases to use for git tags.
// +optional
Expand Down Expand Up @@ -284,3 +247,39 @@ version: "1.0"
// +optional
secrets?: [...#Secret] @go(Secrets,[]Secret)
}

// ProviderGithub contains the configuration for the Github provider.
#ProviderGithub: {
// Credentials contains the credentials to use for Github
// +optional
credentials?: #Secret @go(Credentials)

// Registry contains the Github registry to use.
// +optional
registry?: null | string @go(Registry,*string)
}

// Secret contains the secret provider and a list of mappings
#Secret: {
// Maps contains mappings for Earthly secret names to JSON keys in the secret.
// Mutually exclusive with Name.
// +optional
maps?: {
[string]: string
} @go(Maps,map[string]string)

// Name contains the name of the Earthly secret to use.
// Mutually exclusive with Maps.
// +optional
name?: null | string @go(Name,*string)

// Optional determines if the secret is optional.
// +optional
optional?: null | bool @go(Optional,*bool)

// Path contains the path to the secret.
path: string @go(Path)

// Provider contains the provider to use for the secret.
provider: string @go(Provider)
}
38 changes: 38 additions & 0 deletions lib/project/schema/deployment.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package schema

// Deployment contains the configuration for the deployment of the project.
type Deployment struct {
// Environment contains the environment to deploy the module to.
Environment string `json:"environment"`

// Modules contains the configuration for the deployment modules for the project.
// +optional
Modules *DeploymentModules `json:"modules"`
}

// Deployment contains the configuration for the deployment of the project.
type DeploymentModules struct {
// Main contains the configuration for the main deployment module.
Main Module `json:"main"`

// Support contains the configuration for the support deployment modules.
// +optional
Support map[string]Module `json:"support"`
}

// Module contains the configuration for a deployment module.
type Module struct {
// Container contains the name of the container holding the deployment code.
// Defaults to <module_name>-deployment). For the main module, <module_name> is the project name.
// +optional
Container *string `json:"container"`

// Namespace contains the namespace to deploy the module to.
Namespace string `json:"namespace"`

// Values contains the values to pass to the deployment module.
Values any `json:"values"`

// Version contains the version of the deployment module.
Version string `json:"version"`
}
42 changes: 42 additions & 0 deletions lib/project/schema/deployment_go_gen.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Code generated by cue get go. DO NOT EDIT.

//cue:generate cue get go github.com/input-output-hk/catalyst-forge/lib/project/schema

package schema

// Deployment contains the configuration for the deployment of the project.
#Deployment: {
// Environment contains the environment to deploy the module to.
environment: string @go(Environment)

// Modules contains the configuration for the deployment modules for the project.
// +optional
modules?: null | #DeploymentModules @go(Modules,*DeploymentModules)
}

// Deployment contains the configuration for the deployment of the project.
#DeploymentModules: {
// Main contains the configuration for the main deployment module.
main: #Module @go(Main)

// Support contains the configuration for the support deployment modules.
// +optional
support?: {[string]: #Module} @go(Support,map[string]Module)
}

// Module contains the configuration for a deployment module.
#Module: {
// Container contains the name of the container holding the deployment code.
// Defaults to <module_name>-deployment). For the main module, <module_name> is the project name.
// +optional
container?: null | string @go(Container,*string)

// Namespace contains the namespace to deploy the module to.
namespace: string @go(Namespace)

// Values contains the values to pass to the deployment module.
values: _ @go(Values,any)

// Version contains the version of the deployment module.
version: string @go(Version)
}
Loading

0 comments on commit 9617c01

Please sign in to comment.