-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from OpsLevel/kr/domains-systems
First pass at a hierarchy module
- Loading branch information
Showing
21 changed files
with
213 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
output "all" { | ||
value = data.opslevel_filters.all | ||
} | ||
|
||
output "this" { | ||
value = opslevel_filter.this | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# OpsLevel Hierarchy Sub-Module | ||
|
||
This module is used to model a hierarchy of domains, systems and services in OpsLevel. | ||
|
||
## Inputs | ||
|
||
## Outputs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# OpsLevel Domain Sub-Module | ||
|
||
This module is used to create a 'domain' in OpsLevel. | ||
|
||
## Inputs | ||
|
||
## Outputs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
data "opslevel_domains" "all" {} | ||
|
||
resource "opslevel_domain" "this" { | ||
name = var.name | ||
description = var.description | ||
owner = local.owner | ||
note = var.note | ||
} | ||
|
||
module "systems" { | ||
source = "../system" | ||
for_each = { for system in var.systems : system.name => system } | ||
name = each.value.name | ||
description = each.value.description | ||
domain = opslevel_domain.this.id | ||
owner = each.value.owner | ||
services = each.value.services | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
output "all" { | ||
value = data.opslevel_domains.all.domains | ||
} | ||
|
||
output "this" { | ||
value = opslevel_domain.this | ||
} | ||
|
||
output "systems" { | ||
value = values(module.systems) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
variable "name" { | ||
type = string | ||
description = "The name of the domain." | ||
} | ||
|
||
variable "description" { | ||
type = string | ||
description = "The description of the domain." | ||
default = null | ||
} | ||
|
||
variable "owner" { | ||
type = string | ||
description = "The team that owns the domain." | ||
default = null | ||
} | ||
|
||
variable "note" { | ||
type = string | ||
description = "Additional information about the domain." | ||
default = null | ||
} | ||
|
||
variable "systems" { | ||
type = list(object({ | ||
name = string | ||
description = optional(string) | ||
owner = optional(string) | ||
services = list(string) | ||
})) | ||
default = [] | ||
} | ||
|
||
// TODO: This is us papering over the fact that we cannot use team alias for the owner field in domain - https://github.com/OpsLevel/team-platform/issues/461 | ||
data "opslevel_teams" "all" {} | ||
|
||
locals { | ||
owner = var.owner == null ? null : (startswith(var.owner, "Z2lkOi8v") ? var.owner : flatten([ | ||
for obj in data.opslevel_teams.all.teams : | ||
obj.id if obj.alias == var.owner | ||
])[0]) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../versions.tf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
data "opslevel_domains" "all" {} | ||
|
||
data "opslevel_systems" "all" {} | ||
|
||
module "domains" { | ||
source = "./domain" | ||
for_each = { for domain in var.domains : domain.name => domain } | ||
name = each.value.name | ||
description = each.value.description | ||
owner = each.value.owner | ||
systems = each.value.systems | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
output "all_domains" { | ||
value = data.opslevel_domains.all.domains | ||
} | ||
|
||
output "all_systems" { | ||
value = data.opslevel_systems.all.systems | ||
} | ||
|
||
output "this" { | ||
value = values(module.domains)[*].this | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# OpsLevel System Sub-Module | ||
|
||
This module is used to create a 'system' in OpsLevel. | ||
|
||
## Inputs | ||
|
||
## Outputs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
data "opslevel_systems" "all" {} | ||
|
||
resource "opslevel_system" "this" { | ||
description = var.description | ||
domain = var.domain | ||
name = var.name | ||
note = var.note | ||
owner = local.owner | ||
} | ||
|
||
# TODO: This would be a really clean way to ensure service.parent is set via this module | ||
#resource "opslevel_service_relationship" "this" { | ||
# for_each = { for service in var.services : service => service } | ||
# system = opslevel_system.this.id | ||
# service = each.value | ||
#} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
output "all" { | ||
value = data.opslevel_systems.all | ||
} | ||
|
||
output "this" { | ||
value = opslevel_system.this | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
variable "name" { | ||
type = string | ||
description = "The name for the system." | ||
} | ||
|
||
variable "description" { | ||
type = string | ||
description = "The description for the system." | ||
default = null | ||
} | ||
|
||
variable "domain" { | ||
type = string | ||
description = "The parent domain this system is a child of." | ||
default = null | ||
} | ||
|
||
variable "note" { | ||
type = string | ||
description = "Additional information about the system." | ||
default = null | ||
} | ||
|
||
variable "owner" { | ||
type = string | ||
description = "The team that owns the system." | ||
default = null | ||
} | ||
|
||
variable "services" { | ||
type = list(string) | ||
description = "The services that this system is responsible for." | ||
default = [] | ||
} | ||
|
||
// TODO: This is us papering over the fact that we cannot use team alias for the owner field in system - https://github.com/OpsLevel/team-platform/issues/461 | ||
data "opslevel_teams" "all" {} | ||
|
||
locals { | ||
owner = var.owner == null ? null : (startswith(var.owner, "Z2lkOi8v") ? var.owner : flatten([ | ||
for obj in data.opslevel_teams.all.teams : | ||
obj.id if obj.alias == var.owner | ||
])[0]) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../versions.tf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
variable "domains" { | ||
type = list(object({ | ||
name = string | ||
description = optional(string) | ||
owner = optional(string) | ||
systems = list(object({ | ||
name = string | ||
description = optional(string) | ||
owner = optional(string) | ||
services = list(string) | ||
})) | ||
})) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../versions.tf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
output "all" { | ||
value = data.opslevel_teams.all | ||
} | ||
|
||
output "this" { | ||
value = opslevel_team.this | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
output "all" { | ||
value = data.opslevel_users.all | ||
} | ||
|
||
output "this" { | ||
value = opslevel_user.this | ||
} |