Experiment with intersection types
This change experiments with using intersection types to cut down on some of the boilerplate -- and make reuse easier -- in the service definitions.
This commit is contained in:
parent
ed1eebe7e5
commit
284cec204d
|
@ -7,87 +7,24 @@ service Rack {
|
||||||
// TODO: we probably need a ToString()-like thing for services (e.g., ARN/ID for most AWS ones).
|
// TODO: we probably need a ToString()-like thing for services (e.g., ARN/ID for most AWS ones).
|
||||||
|
|
||||||
resources {
|
resources {
|
||||||
security := new rackSecurity {}
|
security := new rackSecurity { this.properties }
|
||||||
network := new rackNetwork {
|
network := new rackNetwork { this.properties }
|
||||||
existingVpc: existingVpc
|
|
||||||
private: private
|
|
||||||
privateApi: privateApi
|
|
||||||
subnetCIDRs: subnetCIDRs
|
|
||||||
subnetPrivateCIDRs: subnetPrivateCIDRs
|
|
||||||
vpccidr: vpccidr
|
|
||||||
}
|
|
||||||
logging := new rackLogging {
|
logging := new rackLogging {
|
||||||
|
this.properties
|
||||||
role: security.logSubscriptionFilterRole
|
role: security.logSubscriptionFilterRole
|
||||||
}
|
}
|
||||||
storage := new rackStorage {}
|
storage := new rackStorage { this.properties }
|
||||||
services := new rackServices {}
|
services := new rackServices { this.properties}
|
||||||
volumes := new rackVolumes {
|
volumes := new rackVolumes {
|
||||||
|
this.properties
|
||||||
vpc: network.vpc
|
vpc: network.vpc
|
||||||
vpccidr: vpccidr
|
|
||||||
subnets: private ? network.privateSubnets : subnets
|
subnets: private ? network.privateSubnets : subnets
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
properties {
|
properties: rackSecurity & rackNetwork & rackLogging & rackStorage & rackServices & rackVolumes {
|
||||||
// Amazon Machine Image:
|
|
||||||
// http://docs.aws.amazon.com/AmazonECS/latest/developerguide/launch_container_instance.html
|
|
||||||
ami: string = ""
|
|
||||||
// How much cpu should be reserved by the api web process.
|
|
||||||
apiCpu: string = "128"
|
|
||||||
// How much memory should be reserved by the api web process
|
|
||||||
apiMemory: string = "128"
|
|
||||||
// Autoscale rack instances
|
|
||||||
autoscale: bool = false
|
|
||||||
// How much cpu should be reserved by the builder
|
|
||||||
buildCpu: string = "0"
|
|
||||||
// Override the default build image
|
|
||||||
buildImage: string = ""
|
|
||||||
// How much memory should be reserved by the builder
|
|
||||||
buildMemory: string = "1024"
|
|
||||||
// Anonymous identifier
|
|
||||||
clientId: string = "dev@xovnoc.com"
|
|
||||||
// Default container disk size in GB
|
|
||||||
containerDisk: number = 10
|
|
||||||
// Development mode
|
// Development mode
|
||||||
development: bool = false
|
development: bool = false
|
||||||
// Encrypt secrets with KMS
|
|
||||||
encryption: bool = true
|
|
||||||
// Existing VPC ID (if blank a VPC will be created)
|
|
||||||
existingVpc: string = ""
|
|
||||||
// Create applications that are only accessible inside the VPC
|
|
||||||
internal: bool = false
|
|
||||||
// A single line of shell script to run as CloudInit command early during instance boot.
|
|
||||||
instanceBootCommand: string = ""
|
|
||||||
// A single line of shell script to run as CloudInit command late during instance boot.
|
|
||||||
instanceRunCommand: strign = ""
|
|
||||||
// The number of instances in the runtime cluster
|
|
||||||
instanceCount: number<3:> = 3
|
|
||||||
// The type of the instances in the runtime cluster
|
|
||||||
instanceType: string = "t2.small"
|
|
||||||
// The number of instances to update in a batch
|
|
||||||
instanceUpdateBatchSize: number<1:> = 1
|
|
||||||
// SSH key name for access to cluster instances
|
|
||||||
key: string = ""
|
|
||||||
// (REQUIRED) API HTTP password
|
|
||||||
secret password: string<1, 50>
|
|
||||||
// Create non publicly routable resources
|
|
||||||
private: bool: false
|
|
||||||
// Put Rack API Load Balancer in private network
|
|
||||||
privateApi: bool: false
|
|
||||||
// Public Subnet CIDR Blocks
|
|
||||||
subnetCIDRs: string[] = [ "10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24" ]
|
|
||||||
// Private Subnet CIDR Blocks
|
|
||||||
subnetPrivateCIDRs: string = [ "10.0.4.0/24", "10.0.5.0/24", "10.0.6.0/24" ]
|
|
||||||
// Default swap volume size in GB
|
|
||||||
swapSize: number = 5
|
|
||||||
// (REQUIRED) Xovnoc release version
|
|
||||||
version: string<1:>
|
|
||||||
// Default disk size in GB
|
|
||||||
volumeSize: number = 50
|
|
||||||
// VPC CIDR Block
|
|
||||||
vpccidr: string = "10.0.0.0/16"
|
|
||||||
// Dedicated Hardware
|
|
||||||
tenancy: "default" | "dedicated" = "default"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -116,5 +116,33 @@ service rackInstances {
|
||||||
role: instancesLifecycleRole
|
role: instancesLifecycleRole
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
properties {
|
||||||
|
// Amazon Machine Image:
|
||||||
|
// http://docs.aws.amazon.com/AmazonECS/latest/developerguide/launch_container_instance.html
|
||||||
|
ami: string = ""
|
||||||
|
// Default container disk size in GB
|
||||||
|
containerDisk: number = 10
|
||||||
|
// Existing VPC ID (if blank a VPC will be created)
|
||||||
|
existingVpc: string = ""
|
||||||
|
// A single line of shell script to run as CloudInit command early during instance boot.
|
||||||
|
instanceBootCommand: string = ""
|
||||||
|
// A single line of shell script to run as CloudInit command late during instance boot.
|
||||||
|
instanceRunCommand: strign = ""
|
||||||
|
// The number of instances in the runtime cluster
|
||||||
|
instanceCount: number<3:> = 3
|
||||||
|
// The type of the instances in the runtime cluster
|
||||||
|
instanceType: string = "t2.small"
|
||||||
|
// The number of instances to update in a batch
|
||||||
|
instanceUpdateBatchSize: number<1:> = 1
|
||||||
|
// Create non publicly routable resources
|
||||||
|
private: bool: false
|
||||||
|
// Default swap volume size in GB
|
||||||
|
swapSize: number = 5
|
||||||
|
// Default disk size in GB
|
||||||
|
volumeSize: number = 50
|
||||||
|
// Dedicated Hardware
|
||||||
|
tenancy: "default" | "dedicated" = "default"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -180,12 +180,18 @@ service rackNetwork {
|
||||||
}
|
}
|
||||||
|
|
||||||
properties {
|
properties {
|
||||||
existingVpc: string
|
// Existing VPC ID (if blank a VPC will be created)
|
||||||
private: boolean
|
existingVpc: string = ""
|
||||||
privateApi: boolean
|
// Create non publicly routable resources
|
||||||
subnetCIDRs: string[]
|
private: bool: false
|
||||||
subnetPrivateCIDRs: string[]
|
// Put Rack API Load Balancer in private network
|
||||||
vpccidr: string
|
privateApi: bool: false
|
||||||
|
// Public Subnet CIDR Blocks
|
||||||
|
subnetCIDRs: string[] = [ "10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24" ]
|
||||||
|
// Private Subnet CIDR Blocks
|
||||||
|
subnetPrivateCIDRs: string = [ "10.0.4.0/24", "10.0.5.0/24", "10.0.6.0/24" ]
|
||||||
|
// VPC CIDR Block
|
||||||
|
vpccidr: string = "10.0.0.0/16"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -201,5 +201,32 @@ service rackServices {
|
||||||
taskDefinition: rackMonitorTasks
|
taskDefinition: rackMonitorTasks
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
properties {
|
||||||
|
// How much cpu should be reserved by the api web process.
|
||||||
|
apiCpu: string = "128"
|
||||||
|
// How much memory should be reserved by the api web process
|
||||||
|
apiMemory: string = "128"
|
||||||
|
// Autoscale rack instances
|
||||||
|
autoscale: bool = false
|
||||||
|
// How much cpu should be reserved by the builder
|
||||||
|
buildCpu: string = "0"
|
||||||
|
// Override the default build image
|
||||||
|
buildImage: string = ""
|
||||||
|
// How much memory should be reserved by the builder
|
||||||
|
buildMemory: string = "1024"
|
||||||
|
// Anonymous identifier
|
||||||
|
clientId: string = "dev@xovnoc.com"
|
||||||
|
// Create applications that are only accessible inside the VPC
|
||||||
|
internal: bool = false
|
||||||
|
// (REQUIRED) API HTTP password
|
||||||
|
secret password: string<1, 50>
|
||||||
|
// Create non publicly routable resources
|
||||||
|
private: bool: false
|
||||||
|
// (REQUIRED) Xovnoc release version
|
||||||
|
version: string<1:>
|
||||||
|
// VPC CIDR Block
|
||||||
|
vpccidr: string = "10.0.0.0/16"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,8 +32,9 @@ service rackVolumes {
|
||||||
|
|
||||||
properties {
|
properties {
|
||||||
vpc: ec2.VPC
|
vpc: ec2.VPC
|
||||||
vpccidr: string
|
|
||||||
subnets: ec2.Subnet[]
|
subnets: ec2.Subnet[]
|
||||||
|
// VPC CIDR Block
|
||||||
|
vpccidr: string = "10.0.0.0/16"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue