Skip to content

Commit

Permalink
chore: improved openstack network handling
Browse files Browse the repository at this point in the history
Signed-off-by: leonsteinhaeuser <leon.steinhaeuser@tagesspiegel.de>
  • Loading branch information
leonsteinhaeuser committed Feb 1, 2024
1 parent 02edb3b commit 38c3f93
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
6 changes: 3 additions & 3 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ resource "metakube_cluster" "this" {
id = var.openstack_application_credential_id
secret = var.openstack_application_credential_secret
}
network = var.openstack_network_config.network_id != null && var.openstack_network_config.subnet_id != null ? var.openstack_network_config.network_id : null
subnet_id = var.openstack_network_config.network_id != null && var.openstack_network_config.subnet_id != null ? var.openstack_network_config.subnet_id : null
subnet_cidr = (var.openstack_network_config.network_id == null && var.openstack_network_config.subnet_id == null) && var.openstack_network_config.subnet_cidr != null ? var.openstack_network_config.subnet_cidr : null
network = var.openstack_network_config.network_name != null && (var.openstack_network_config.subnet_id == null && var.openstack_network_config.subnet_cidr == null) ? var.openstack_network_config.network_name : null
subnet_id = var.openstack_network_config.subnet_id != null && (var.openstack_network_config.network_name == null && var.openstack_network_config.subnet_cidr == null) ? var.openstack_network_config.subnet_id : null
subnet_cidr = var.openstack_network_config.subnet_cidr != null && (var.openstack_network_config.network_name == null && var.openstack_network_config.subnet_id == null) ? var.openstack_network_config.subnet_cidr : null
}
}
// configure OIDC authentication
Expand Down
11 changes: 8 additions & 3 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,15 @@ variable "openstack_application_credential_secret" {

variable "openstack_network_config" {
type = object({
network_id = optional(string)
subnet_id = optional(string)
subnet_cidr = optional(string)
network_name = optional(string)
subnet_id = optional(string)
subnet_cidr = optional(string)
})
description = "The network configuration for the metakube cluster. Either network_name or subnet_id or subnet_cidr must be set."
validation {
condition = (var.openstack_network_config.network_name != null && var.openstack_network_config.subnet_id != null) || (var.openstack_network_config.network_name != null && var.openstack_network_config.subnet_cidr != null) || (var.openstack_network_config.subnet_id != null && var.openstack_network_config.subnet_cidr != null)
error_message = "Only one of the fields network_name, subnet_id or subnet_cidr must be set."
}
}

variable "syseleven_auth_realm" {
Expand Down

0 comments on commit 38c3f93

Please sign in to comment.