Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions nullplatform/parameter_storage_definition/data.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# A non-2xx is not an error for the http provider: the body would render as the template.
data "http" "parameter_storage_spec_template" {
url = "${var.repository_parameter_storage_spec}/${var.repository_parameter_storage_spec_branch}/${var.template_path}"

lifecycle {
postcondition {
condition = self.status_code == 200
error_message = "Fetch of ${self.url} returned HTTP ${self.status_code}, expected 200."
}
}
}

data "external" "parameter_storage_spec" {
Expand Down
3 changes: 3 additions & 0 deletions nullplatform/parameter_storage_definition/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ variable "nrn" {
type = string
}

# Unused here (the provider is configured at the root) but passed by consumers, so
# deleting it is a breaking interface change.
# tflint-ignore: terraform_unused_declarations
variable "np_api_key" {
description = "nullplatform API key. Kept for interface consistency across the parameter-storage modules; the provider is configured at the root."
type = string
Expand Down
33 changes: 33 additions & 0 deletions nullplatform/scope_definition/data.tf
Original file line number Diff line number Diff line change
@@ -1,22 +1,55 @@
################################################################################
# Template Fetching
#
# A non-2xx is not an error for the http provider: without these postconditions
# a missing template's body (`404: Not Found`) renders as the template and dies
# later in jq. Branch defaults track a moving ref, so an upstream rename can
# break an already-applied state.
################################################################################
data "http" "service_spec_template" {
url = "${var.repository_service_spec}/${var.repository_service_spec_branch}/${var.service_path}/specs/service-spec.json.tpl"

lifecycle {
postcondition {
condition = self.status_code == 200
error_message = "Fetch of ${self.url} returned HTTP ${self.status_code}, expected 200."
}
}
}

data "http" "scope_type_template" {
url = "${var.repository_scope_template}/${var.repository_scope_template_branch}/${var.service_path}/specs/scope-type-definition.json.tpl"

lifecycle {
postcondition {
condition = self.status_code == 200
error_message = "Fetch of ${self.url} returned HTTP ${self.status_code}, expected 200."
}
}
}

data "http" "action_templates" {
for_each = local.static_action_specs
url = "${var.repository_action_templates}/${var.repository_action_templates_branch}/${var.service_path}/specs/actions/${each.key}.json.tpl"

lifecycle {
postcondition {
condition = self.status_code == 200
error_message = "Fetch of ${self.url} returned HTTP ${self.status_code}, expected 200. Check that the action name is spelled as the template file in the scope repository."
}
}
}

data "http" "scope_configuration_template" {
count = var.create_scope_configuration ? 1 : 0
url = "${var.repository_scope_template}/${var.repository_scope_template_branch}/${var.service_path}/specs/scope-configuration.json.tpl"

lifecycle {
postcondition {
condition = self.status_code == 200
error_message = "Fetch of ${self.url} returned HTTP ${self.status_code}, expected 200."
}
}
}

# Process service specification template using gomplate with NRN variable
Expand Down
8 changes: 8 additions & 0 deletions nullplatform/scope_definition_agent_association/data.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,16 @@
# Notification Channel Template Fetching
################################################################################

# A non-2xx is not an error for the http provider: the body would render as the template.
data "http" "notification_channel_template" {
url = "${var.repository_notification_channel}/${var.repository_notification_channel_branch}/${var.service_path}/specs/notification-channel.json.tpl"

lifecycle {
postcondition {
condition = self.status_code == 200
error_message = "Fetch of ${self.url} returned HTTP ${self.status_code}, expected 200."
}
}
}

################################################################################
Expand Down
28 changes: 28 additions & 0 deletions nullplatform/service_definition/data.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
################################################################################
# Template Fetching
#
# A non-2xx is not an error for the http provider: without these postconditions
# a missing template's body renders as the template and fails later. On private
# repositories a 401/403/404 usually means the token or branch is wrong.
################################################################################
data "http" "service_spec_template" {
count = var.git_provider != "local" ? 1 : 0
url = (
Expand All @@ -6,6 +13,13 @@ data "http" "service_spec_template" {
"${local.gitlab_api_file_prefix}${local.gitlab_path_sep}specs%2Fservice-spec.json.tpl/raw?ref=${var.repository_branch}"
)
request_headers = local.auth_headers

lifecycle {
postcondition {
condition = self.status_code == 200
error_message = "Fetch of ${self.url} returned HTTP ${self.status_code}, expected 200."
}
}
}

data "http" "action_templates" {
Expand All @@ -16,6 +30,13 @@ data "http" "action_templates" {
"${local.gitlab_api_file_prefix}${local.gitlab_path_sep}specs%2Factions%2F${each.key}.json.tpl/raw?ref=${var.repository_branch}"
)
request_headers = local.auth_headers

lifecycle {
postcondition {
condition = self.status_code == 200
error_message = "Fetch of ${self.url} returned HTTP ${self.status_code}, expected 200. Check that the action name is spelled as the template file in the service repository."
}
}
}

data "http" "link_templates" {
Expand All @@ -26,4 +47,11 @@ data "http" "link_templates" {
"${local.gitlab_api_file_prefix}${local.gitlab_path_sep}specs%2Flinks%2F${each.key}.json.tpl/raw?ref=${var.repository_branch}"
)
request_headers = local.auth_headers

lifecycle {
postcondition {
condition = self.status_code == 200
error_message = "Fetch of ${self.url} returned HTTP ${self.status_code}, expected 200. Check that the link name is spelled as the template file in the service repository."
}
}
}
Loading