C4-PlantUML icon indicating copy to clipboard operation
C4-PlantUML copied to clipboard

Control Ordering Of Multiple Relationships Between Same Elements

Open DarwinJS opened this issue 1 year ago • 2 comments

In the attached I cannot control the sequencing of the three connection types so that they go in the order SSL, Token Auth, Control.

Is there a way to do it?

image

@startuml
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Component.puml

'LAYOUT_LANDSCAPE()

title GitLab Runner and Kubernetes Agent Connections

AddRelTag("network", $textColor="red", $lineColor="red", $lineStyle = DashedLine())
AddRelTag("auth", $textColor="orange", $lineColor="orange", $lineStyle = DashedLine())
AddRelTag("control", $textColor="green", $lineColor="green")

Boundary(network, "Any Networks", "Private, Internet, etc")  {
Boundary(runnerenv, "Any Environment", "Private,Cloud,etc") {
  Container(glrunner, "GitLab Runner") {
    Component(glrunnertradconn, "Job Acquisition Connection")
    Component(glrunneragtconn, "Agent Connection")
    Lay_D(glrunnertradconn,glrunneragtconn)
  }
}

Boundary(glinstenv, "Any Environment", "Private,Cloud,etc") {
Boundary(glinstance, "Any GitLab Instance", "SaaS, Self-Managed") {
  Component(kas, "KAS", "Spring Bean")
  Component(glrails, "GitLab Rails",)
}
}

Rel(glrunnertradconn,glrunneragtconn, "K8s Command", "w/ KUBE_CONTEXT")

'Runner Polling Connection to Job Queue
Rel_R(glrunnertradconn, glrails, "Initiates", "SSL", $tags="network")
Rel_R(glrunnertradconn, glrails, "Initiates", "Token Auth", $tags="auth")
Rel_L(glrails, glrunnertradconn, "Control","Poll & Pull Jobs", $tags="control")

Boundary(k8senv, "Any Environment", "Private,Cloud,etc") {
Boundary(kasnet, "Any K8s Cluster") {
  Component(k8sagent, "GL Agent for K8s")
}
}

'Runner Connection to KAS
Rel_R(glrunneragtconn, kas, "Initiates", "SSL", $tags="network")
Rel_R(glrunneragtconn, kas, "Control","Push K8s CMDs", $tags="control")
Rel_R(glrunneragtconn, kas, "Starts", "Token Auth", $tags="auth")

'K8s Agent to KAS
Rel_L(k8sagent, kas, "Initiates", "SSL", $tags="network")
Rel_L(k8sagent, kas, "Initiates", "Token Auth", $tags="auth")
Rel_R(kas, k8sagent, "Control","Poll & Pull Manifests", $tags="control")

'Layouts prioritized in order - put outer most first
Lay_R(runnerenv,glinstenv)
Lay_R(glinstenv,k8sagent)
Lay_D(glrails,kas) 

'Rel_R(glrunner,kas, "Control", "Push CD", $tags="control")
'Rel_R(kas,k8sagent, "Control", "Push CD", $tags="control")
}
SHOW_LEGEND()

@enduml

DarwinJS avatar Sep 09 '22 18:09 DarwinJS

I've not come across a way to influence the order that links are shown in, but I could look some more... @kirchsth Do you know if such a thing exists?

A possible solution might be to use a sub-graph, but I'd have to do some experiments to come up with an example.

Potherca avatar Sep 13 '22 07:09 Potherca

Hi @DarwinJS,

I have no final solution to change the order of the lines, but if you want to have a specific sequence then you can use a C4_Dynamic diagram and all calls are automatically numbered like below

@startuml
' Dynamic activates automatically numbering 

skinparam linestyle normal

!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Dynamic.puml

AddRelTag("network", $textColor="red", $lineColor="red", $lineStyle = DashedLine())
AddRelTag("auth", $textColor="orange", $lineColor="orange", $lineStyle = DashedLine())
AddRelTag("control", $textColor="green", $lineColor="green")

Component(glrunnertradconn, "Job Acquisition Connection")
Component(glrunneragtconn, "Agent Connection")

Component(kas, "KAS", "Spring Bean")
Component(glrails, "GitLab Rails")

Rel_R(glrunnertradconn,glrunneragtconn, "K8s Command", "w/ KUBE_CONTEXT")

'Runner Polling Connection to Job Queue
Rel(glrunnertradconn, glrails, "Initiates", "SSL", $tags="network")
Rel(glrunnertradconn, glrails, "Initiates", "Token Auth", $tags="auth")
Rel(glrunnertradconn, glrails, "Control","Poll & Pull Jobs", $tags="control")

Component(k8sagent, "GL Agent for K8s")

'Runner Connection to KAS
' or use custom number 
' With e.g. Index($offset=1) or SetIndex(6) you can defined new starting numbers

RelIndex(Index().a, glrunneragtconn, kas, "Initiates", "SSL", $tags="network")
RelIndex(LastIndex().b, glrunneragtconn, kas, "Control","Push K8s CMDs", $tags="control")
RelIndex(LastIndex().c, glrunneragtconn, kas, "Starts", "Token Auth", $tags="auth")

RelIndex(Index().a-c, kas,k8sagent, "ICS calls")

RelIndex(SetIndex(7), kas,k8sagent, "Control", "Push CD", $tags="control")

Lay_R(glrunnertradconn, glrails)

SHOW_FLOATING_LEGEND()
@enduml

kirchsth avatar Sep 17 '22 20:09 kirchsth

Hi @DarwinJS, did it help? Can we close it? BR Helmut

kirchsth avatar Nov 12 '22 18:11 kirchsth