diff --git a/dsl/deployment.go b/dsl/deployment.go index 4c80daa0..117b5f25 100644 --- a/dsl/deployment.go +++ b/dsl/deployment.go @@ -113,7 +113,7 @@ func DeploymentNode(name string, args ...interface{}) *expr.DeploymentNode { eval.ReportError("DeploymentNode: " + err.Error()) return nil } - one := 1 + one := "1" node := &expr.DeploymentNode{ Element: &expr.Element{ Name: name, @@ -293,18 +293,20 @@ func ContainerInstance(container interface{}, dsl ...func()) *expr.ContainerInst // // Instances must appear in a DeploymentNode expression. // -// Instances accepts a single argument which is the number. +// Instances accepts a single argument which is a string. +// +// Instances can either be a static number, or a range (e.g. 0..1, 1..3, 5..10, 0..N, 0..*, 1..N, 1..*, etc). // // Example: // // var _ = Design(func() { // DeploymentEnvironment("Production", func() { // DeploymentNode("Web app", func() { -// Instances(3) +// Instances("3") // }) // }) // }) -func Instances(n int) { +func Instances(n string) { node, ok := eval.Current().(*expr.DeploymentNode) if !ok { eval.IncompatibleDSL() diff --git a/examples/big_bank_plc/model/model.go b/examples/big_bank_plc/model/model.go index a51ca158..51db30e4 100644 --- a/examples/big_bank_plc/model/model.go +++ b/examples/big_bank_plc/model/model.go @@ -262,7 +262,7 @@ var _ = Design("Big Bank plc", "This is an example workspace to illustrate the k BigBankAPI = DeploymentNode("bigbank-api***", "A web server residing in the web server farm, accessed via F5 BIG-IP LTMs.", "Ubuntu 16.04 LTS", func() { Tag("Element", "Deployment Node") - Instances(8) + Instances("8") Prop("Location", "London and Reading") LiveAPIApp = DeploymentNode("Apache Tomcat", "An open source Java EE web server.", "Apache Tomcat 8.x", func() { @@ -308,7 +308,7 @@ var _ = Design("Big Bank plc", "This is an example workspace to illustrate the k BigBankWeb = DeploymentNode("bigbank-web***", "A web server residing in the web server farm, accessed via F5 BIG-IP LTMs.", "Ubuntu 16.04 LTS", func() { Tag("Element", "Deployment Node") - Instances(4) + Instances("4") Prop("Location", "London and Reading") LiveWebApp = DeploymentNode("Apache Tomcat", "An open source Java EE web server.", "Apache Tomcat 8.x", func() { diff --git a/expr/deployment.go b/expr/deployment.go index 9176061b..b601409b 100644 --- a/expr/deployment.go +++ b/expr/deployment.go @@ -18,7 +18,7 @@ type ( Children []*DeploymentNode InfrastructureNodes []*InfrastructureNode ContainerInstances []*ContainerInstance - Instances *int + Instances *string Environment string } diff --git a/mdl/deployment.go b/mdl/deployment.go index 0a949bde..ac522fb7 100644 --- a/mdl/deployment.go +++ b/mdl/deployment.go @@ -15,7 +15,7 @@ type ( // node resides (e.g. "Development", "Live", etc). Environment string `json:"environment"` // Instances is the number of instances. - Instances *int `json:"instances,omitempty"` + Instances *string `json:"instances,omitempty"` // Tags attached to element as comma separated list if any. Tags string `json:"tags,omitempty"` // URL where more information about this element can be found. diff --git a/stz/client_test.go b/stz/client_test.go index 62eba125..2d1a725e 100644 --- a/stz/client_test.go +++ b/stz/client_test.go @@ -550,7 +550,7 @@ var bigBankPLC = `{ "description": "A developer laptop.", "environment": "Development", "technology": "Microsoft Windows 10 or Apple macOS", - "instances": 1, + "instances": "1", "children": [ { "id": "55", @@ -559,7 +559,7 @@ var bigBankPLC = `{ "description": "A Docker container.", "environment": "Development", "technology": "Docker", - "instances": 1, + "instances": "1", "children": [ { "id": "56", @@ -568,7 +568,7 @@ var bigBankPLC = `{ "description": "A development database.", "environment": "Development", "technology": "Oracle 12c", - "instances": 1, + "instances": "1", "containerInstances": [ { "id": "57", @@ -593,7 +593,7 @@ var bigBankPLC = `{ "description": "A Docker container.", "environment": "Development", "technology": "Docker", - "instances": 1, + "instances": "1", "children": [ { "id": "52", @@ -607,7 +607,7 @@ var bigBankPLC = `{ "description": "An open source Java EE web server.", "environment": "Development", "technology": "Apache Tomcat 8.x", - "instances": 1, + "instances": "1", "containerInstances": [ { "id": "54", @@ -660,7 +660,7 @@ var bigBankPLC = `{ "name": "Web Browser", "environment": "Development", "technology": "Chrome, Firefox, Safari, or Edge", - "instances": 1, + "instances": "1", "containerInstances": [ { "id": "60", @@ -695,7 +695,7 @@ var bigBankPLC = `{ "name": "Big Bank plc", "environment": "Live", "technology": "Big Bank plc data center", - "instances": 1, + "instances": "1", "children": [ { "id": "73", @@ -707,7 +707,7 @@ var bigBankPLC = `{ "description": "A web server residing in the web server farm, accessed via F5 BIG-IP LTMs.", "environment": "Live", "technology": "Ubuntu 16.04 LTS", - "instances": 8, + "instances": "8", "children": [ { "id": "74", @@ -721,7 +721,7 @@ var bigBankPLC = `{ "description": "An open source Java EE web server.", "environment": "Live", "technology": "Apache Tomcat 8.x", - "instances": 1, + "instances": "1", "containerInstances": [ { "id": "75", @@ -770,7 +770,7 @@ var bigBankPLC = `{ "description": "The primary database server.", "environment": "Live", "technology": "Ubuntu 16.04 LTS", - "instances": 1, + "instances": "1", "children": [ { "id": "79", @@ -789,7 +789,7 @@ var bigBankPLC = `{ ], "environment": "Live", "technology": "Oracle 12c", - "instances": 1, + "instances": "1", "containerInstances": [ { "id": "80", @@ -817,7 +817,7 @@ var bigBankPLC = `{ "description": "The secondary database server.", "environment": "Live", "technology": "Ubuntu 16.04 LTS", - "instances": 1, + "instances": "1", "children": [ { "id": "83", @@ -826,7 +826,7 @@ var bigBankPLC = `{ "description": "A secondary, standby database server, used for failover purposes only.", "environment": "Live", "technology": "Oracle 12c", - "instances": 1, + "instances": "1", "containerInstances": [ { "id": "84", @@ -854,7 +854,7 @@ var bigBankPLC = `{ "description": "A web server residing in the web server farm, accessed via F5 BIG-IP LTMs.", "environment": "Live", "technology": "Ubuntu 16.04 LTS", - "instances": 4, + "instances": "4", "children": [ { "id": "70", @@ -868,7 +868,7 @@ var bigBankPLC = `{ "description": "An open source Java EE web server.", "environment": "Live", "technology": "Apache Tomcat 8.x", - "instances": 1, + "instances": "1", "containerInstances": [ { "id": "71", @@ -906,7 +906,7 @@ var bigBankPLC = `{ "name": "Customer's computer", "environment": "Live", "technology": "Microsoft Windows or Apple macOS", - "instances": 1, + "instances": "1", "children": [ { "id": "66", @@ -914,7 +914,7 @@ var bigBankPLC = `{ "name": "Web Browser", "environment": "Live", "technology": "Chrome, Firefox, Safari, or Edge", - "instances": 1, + "instances": "1", "containerInstances": [ { "id": "67", @@ -949,7 +949,7 @@ var bigBankPLC = `{ "name": "Customer's mobile device", "environment": "Live", "technology": "Apple iOS or Android", - "instances": 1, + "instances": "1", "containerInstances": [ { "id": "64",