deployment {
    environment otcKubernetes 'OTC Kubernetes' {
        description 'OTC Container Cluster Engine hosting EDP platform'
        technology 'Kubernetes'
        icon tech:kubernetes

        cluster edpCluster 'EDP Cluster' {
            description 'EDP platform cluster'

            instanceOf edp.forgejo {
                description 'Forgejo - Git platform with Actions'
            }

            instanceOf edp.forgejoActions {
                description 'CI/CD orchestration for Forgejo'
            }

            garmContainer = instanceOf edp.garm {
                description 'GARM container with runner orchestration'
            }

            garmService = instanceOf edp.garm.garm {
                description 'GARM - Runner lifecycle manager'
            }

            instanceOf edp.garm.providerEdgeConnect {
                description 'GARM Provider for Edge Connect'
            }
        }
    }

    environment edgeConnectEnv 'Edge Connect' {
        description 'Edge infrastructure for ephemeral runner deployment'
        technology 'Edge Connect Platform'
        icon tech:docker

        computeressource runnerInfrastructure 'Runner Infrastructure' {
            description 'Dynamically provisioned runner instances'

            instanceOf forgejoRunner {
                description 'Ephemeral Forgejo Actions runner'
                -> otcKubernetes.edpCluster.forgejo 'registers with and picks up jobs'
                -> otcKubernetes.edpCluster.garmService 'retrieves bootstrap information'
            }
        }
    }
}

views {
    deployment view forgejoGarmArchitecture {
        title 'Architecture of Forgejo, Garm and Edge Connect'
        description 'Deployment architecture showing GARM orchestrating ephemeral runners on Edge Connect for Forgejo Actions'

        include
            otcKubernetes,
            otcKubernetes.*,
            otcKubernetes.**,
            edgeConnectEnv,
            edgeConnectEnv.*,
            edgeConnectEnv.**

        style otcKubernetes {
            color blue
        }

        style edgeConnectEnv {
            color green
        }
    }
}
