From 05f1bc9f74b7a6a1d07c710295945bd769adc53c Mon Sep 17 00:00:00 2001 From: Felipe Gonzalez Date: Mon, 4 Mar 2024 15:01:24 -0300 Subject: [PATCH] fix: Add extension subdomain variable (#31) --- bootstrap/feature/main.tf | 4 ++++ bootstrap/feature/operator.tf | 5 +++++ operator/Cargo.lock | 2 +- operator/Cargo.toml | 2 +- operator/src/config.rs | 4 +++- operator/src/helpers/mod.rs | 6 +++--- 6 files changed, 17 insertions(+), 6 deletions(-) diff --git a/bootstrap/feature/main.tf b/bootstrap/feature/main.tf index 844ceaf..e7b181a 100644 --- a/bootstrap/feature/main.tf +++ b/bootstrap/feature/main.tf @@ -36,6 +36,10 @@ variable "ingress_class" { type = string } +variable "extension_subdomain" { + type = string +} + variable "dns_zone" { default = "demeter.run" } diff --git a/bootstrap/feature/operator.tf b/bootstrap/feature/operator.tf index 9f937d8..5742733 100644 --- a/bootstrap/feature/operator.tf +++ b/bootstrap/feature/operator.tf @@ -90,6 +90,11 @@ resource "kubernetes_deployment_v1" "operator" { value = var.ingress_class } + env { + name = "EXTENSION_SUBDOMAIN" + value = var.extension_subdomain + } + env { name = "DNS_ZONE" value = var.dns_zone diff --git a/operator/Cargo.lock b/operator/Cargo.lock index 62ac16e..8eecb9e 100644 --- a/operator/Cargo.lock +++ b/operator/Cargo.lock @@ -615,7 +615,7 @@ dependencies = [ [[package]] name = "ext-cardano-kupo" -version = "0.1.1" +version = "0.1.2" dependencies = [ "actix-web", "argon2", diff --git a/operator/Cargo.toml b/operator/Cargo.toml index 7c08de9..1d0c738 100644 --- a/operator/Cargo.toml +++ b/operator/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ext-cardano-kupo" -version = "0.1.1" +version = "0.1.2" edition = "2021" default-run = "controller" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/operator/src/config.rs b/operator/src/config.rs index 0188fd3..368f4c7 100644 --- a/operator/src/config.rs +++ b/operator/src/config.rs @@ -14,6 +14,7 @@ pub struct Config { pub dns_zone: String, pub ingress_class: String, + pub extension_subdomain: String, pub api_key_salt: String, pub metrics_delay: Duration, @@ -30,7 +31,8 @@ impl Config { pub fn from_env() -> Self { Self { dns_zone: env::var("DNS_ZONE").unwrap_or("demeter.run".into()), - ingress_class: env::var("INGRESS_CLASS").unwrap_or("kupo-m1".into()), + ingress_class: env::var("INGRESS_CLASS").unwrap_or("kupo-v1".into()), + extension_subdomain: env::var("EXTENSION_SUBDOMAIN").unwrap_or("kupo-m1".into()), api_key_salt: env::var("API_KEY_SALT").unwrap_or("kupo-salt".into()), metrics_delay: Duration::from_secs( diff --git a/operator/src/helpers/mod.rs b/operator/src/helpers/mod.rs index 3e39f1d..991ae26 100644 --- a/operator/src/helpers/mod.rs +++ b/operator/src/helpers/mod.rs @@ -88,14 +88,14 @@ pub fn build_hostname( kupo_version: &Option, ) -> (String, String) { let config = get_config(); - let ingress_class = &config.ingress_class; + let extension_subdomain = &config.extension_subdomain; let dns_zone = &config.dns_zone; let version = kupo_version .clone() .unwrap_or(config.default_kupo_version.to_string()); - let hostname = format!("{network}-v{version}.{ingress_class}.{dns_zone}"); - let hostname_key = format!("{key}.{network}-v{version}.{ingress_class}.{dns_zone}"); + let hostname = format!("{network}-v{version}.{extension_subdomain}.{dns_zone}"); + let hostname_key = format!("{key}.{network}-v{version}.{extension_subdomain}.{dns_zone}"); (hostname, hostname_key) }