Skip to content

Commit

Permalink
Adds support for tags on deployment nodes.
Browse files Browse the repository at this point in the history
  • Loading branch information
simonbrowndotje committed Jan 11, 2020
1 parent 3d2f4e7 commit fe79bb8
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 19 deletions.
17 changes: 16 additions & 1 deletion Structurizr.Core.Tests/Model/DeploymentNodeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,24 @@ public void test_getRequiredTags()
public void test_getTags()
{
DeploymentNode deploymentNode = new DeploymentNode();
Assert.Equal("", deploymentNode.Tags);
Assert.Equal("Element,Deployment Node", deploymentNode.Tags);
}


[Fact]
public void Test_RemoveTags_DoesNotRemoveRequiredTags()
{
DeploymentNode deploymentNode = new DeploymentNode();
Assert.True(deploymentNode.Tags.Contains(Tags.Element));
Assert.True(deploymentNode.Tags.Contains(Tags.DeploymentNode));

deploymentNode.RemoveTag(Tags.DeploymentNode);
deploymentNode.RemoveTag(Tags.Element);

Assert.True(deploymentNode.Tags.Contains(Tags.Element));
Assert.True(deploymentNode.Tags.Contains(Tags.DeploymentNode));
}

[Fact]
public void test_add_ThrowsAnException_WhenAContainerIsNotSpecified()
{
Expand Down
17 changes: 5 additions & 12 deletions Structurizr.Core/Model/DeploymentNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,13 @@ internal DeploymentNode()
Environment = DefaultDeploymentEnvironment;
}

public override string Tags {
get
{
return "";
}
set
{
// no-op
}
}

public override List<string> GetRequiredTags()
{
return new List<string>();
return new List<string>
{
Structurizr.Tags.Element,
Structurizr.Tags.DeploymentNode
};
}

public override string CanonicalName
Expand Down
2 changes: 1 addition & 1 deletion Structurizr.Core/Model/ModelItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public IEnumerable<string> GetAllTags()
}

[DataMember(Name = "tags", EmitDefaultValue = false)]
public virtual string Tags
public string Tags
{
get
{
Expand Down
1 change: 1 addition & 0 deletions Structurizr.Core/Model/Tags.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public sealed class Tags
public const string Synchronous = "Synchronous";
public const string Asynchronous = "Asynchronous";

public const string DeploymentNode = "Deployment Node";
public const string ContainerInstance = "Container Instance";

}
Expand Down
12 changes: 7 additions & 5 deletions Structurizr.Examples/BigBankPlc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,13 @@ public static Workspace Create()
.AddDeploymentNode("Database Server", "A development database.", "Oracle 12c")
.Add(database);

developerLaptop.AddDeploymentNode("Web Browser", "", "Google Chrome, Mozilla Firefox, Apple Safari or Microsoft Edge").Add(singlePageApplication);
developerLaptop.AddDeploymentNode("Web Browser", "", "Chrome, Firefox, Safari, or Edge").Add(singlePageApplication);

DeploymentNode customerMobileDevice = model.AddDeploymentNode("Live", "Customer's mobile device", "", "Apple iOS or Android");
customerMobileDevice.Add(mobileApp);

DeploymentNode customerComputer = model.AddDeploymentNode("Live", "Customer's computer", "", "Microsoft Windows or Apple macOS");
customerComputer.AddDeploymentNode("Web Browser", "", "Google Chrome, Mozilla Firefox, Apple Safari or Microsoft Edge").Add(singlePageApplication);
customerComputer.AddDeploymentNode("Web Browser", "", "Chrome, Firefox, Safari, or Edge").Add(singlePageApplication);

DeploymentNode bigBankDataCenter = model.AddDeploymentNode("Live", "Big Bank plc", "", "Big Bank plc data center");

Expand All @@ -135,9 +135,11 @@ public static Workspace Create()
DeploymentNode primaryDatabaseServer = bigBankDataCenter.AddDeploymentNode("bigbank-db01", "The primary database server.", "Ubuntu 16.04 LTS", 1, DictionaryUtils.Create("Location=London"))
.AddDeploymentNode("Oracle - Primary", "The primary, live database server.", "Oracle 12c");
primaryDatabaseServer.Add(database);

DeploymentNode secondaryDatabaseServer = bigBankDataCenter.AddDeploymentNode("bigbank-db02", "The secondary database server.", "Ubuntu 16.04 LTS", 1, DictionaryUtils.Create("Location=Reading"))
.AddDeploymentNode("Oracle - Secondary", "A secondary, standby database server, used for failover purposes only.", "Oracle 12c");

DeploymentNode bigBankdb02 = bigBankDataCenter.AddDeploymentNode("bigbank-db02", "The secondary database server.", "Ubuntu 16.04 LTS", 1, DictionaryUtils.Create("Location=Reading"));
bigBankdb02.AddTags(FailoverTag);
DeploymentNode secondaryDatabaseServer = bigBankdb02.AddDeploymentNode("Oracle - Secondary", "A secondary, standby database server, used for failover purposes only.", "Oracle 12c");
secondaryDatabaseServer.AddTags(FailoverTag);
ContainerInstance secondaryDatabase = secondaryDatabaseServer.Add(database);

model.Relationships.Where(r=>r.Destination.Equals(secondaryDatabase)).ToList().ForEach(r=>r.AddTags(FailoverTag));
Expand Down
1 change: 1 addition & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- Added A1 and A0 paper sizes.
- Adds support for themes.
- Adds support for tags on deployment nodes.

## 0.9.5 (24th December 2019)

Expand Down

0 comments on commit fe79bb8

Please sign in to comment.