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).
|
||||
|
||||
resources {
|
||||
security := new rackSecurity {}
|
||||
network := new rackNetwork {
|
||||
existingVpc: existingVpc
|
||||
private: private
|
||||
privateApi: privateApi
|
||||
subnetCIDRs: subnetCIDRs
|
||||
subnetPrivateCIDRs: subnetPrivateCIDRs
|
||||
vpccidr: vpccidr
|
||||
}
|
||||
security := new rackSecurity { this.properties }
|
||||
network := new rackNetwork { this.properties }
|
||||
logging := new rackLogging {
|
||||
this.properties
|
||||
role: security.logSubscriptionFilterRole
|
||||
}
|
||||
storage := new rackStorage {}
|
||||
services := new rackServices {}
|
||||
storage := new rackStorage { this.properties }
|
||||
services := new rackServices { this.properties}
|
||||
volumes := new rackVolumes {
|
||||
this.properties
|
||||
vpc: network.vpc
|
||||
vpccidr: vpccidr
|
||||
subnets: private ? network.privateSubnets : subnets
|
||||
}
|
||||
}
|
||||
|
||||
properties {
|
||||
// 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
|
||||
properties: rackSecurity & rackNetwork & rackLogging & rackStorage & rackServices & rackVolumes {
|
||||
// Development mode
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
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 {
|
||||
existingVpc: string
|
||||
private: boolean
|
||||
privateApi: boolean
|
||||
subnetCIDRs: string[]
|
||||
subnetPrivateCIDRs: string[]
|
||||
vpccidr: string
|
||||
// Existing VPC ID (if blank a VPC will be created)
|
||||
existingVpc: string = ""
|
||||
// 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" ]
|
||||
// VPC CIDR Block
|
||||
vpccidr: string = "10.0.0.0/16"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -201,5 +201,32 @@ service rackServices {
|
|||
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 {
|
||||
vpc: ec2.VPC
|
||||
vpccidr: string
|
||||
subnets: ec2.Subnet[]
|
||||
// VPC CIDR Block
|
||||
vpccidr: string = "10.0.0.0/16"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue