Skip to content

Commit

Permalink
change deployment node instances to *string (#340)
Browse files Browse the repository at this point in the history
* change deployment node instacnes to *string

* fixed grammer
  • Loading branch information
beffge authored Jan 13, 2023
1 parent 7b84bd2 commit 5582167
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 26 deletions.
10 changes: 6 additions & 4 deletions dsl/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions examples/big_bank_plc/model/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion expr/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type (
Children []*DeploymentNode
InfrastructureNodes []*InfrastructureNode
ContainerInstances []*ContainerInstance
Instances *int
Instances *string
Environment string
}

Expand Down
2 changes: 1 addition & 1 deletion mdl/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
36 changes: 18 additions & 18 deletions stz/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -559,7 +559,7 @@ var bigBankPLC = `{
"description": "A Docker container.",
"environment": "Development",
"technology": "Docker",
"instances": 1,
"instances": "1",
"children": [
{
"id": "56",
Expand All @@ -568,7 +568,7 @@ var bigBankPLC = `{
"description": "A development database.",
"environment": "Development",
"technology": "Oracle 12c",
"instances": 1,
"instances": "1",
"containerInstances": [
{
"id": "57",
Expand All @@ -593,7 +593,7 @@ var bigBankPLC = `{
"description": "A Docker container.",
"environment": "Development",
"technology": "Docker",
"instances": 1,
"instances": "1",
"children": [
{
"id": "52",
Expand All @@ -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",
Expand Down Expand Up @@ -660,7 +660,7 @@ var bigBankPLC = `{
"name": "Web Browser",
"environment": "Development",
"technology": "Chrome, Firefox, Safari, or Edge",
"instances": 1,
"instances": "1",
"containerInstances": [
{
"id": "60",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -789,7 +789,7 @@ var bigBankPLC = `{
],
"environment": "Live",
"technology": "Oracle 12c",
"instances": 1,
"instances": "1",
"containerInstances": [
{
"id": "80",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -906,15 +906,15 @@ var bigBankPLC = `{
"name": "Customer's computer",
"environment": "Live",
"technology": "Microsoft Windows or Apple macOS",
"instances": 1,
"instances": "1",
"children": [
{
"id": "66",
"tags": "Element,Deployment Node",
"name": "Web Browser",
"environment": "Live",
"technology": "Chrome, Firefox, Safari, or Edge",
"instances": 1,
"instances": "1",
"containerInstances": [
{
"id": "67",
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 5582167

Please sign in to comment.