Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Remove enum options for network on CRD #32

Merged
merged 1 commit into from
Mar 22, 2024
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
6 changes: 0 additions & 6 deletions bootstrap/crds/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,6 @@ resource "kubernetes_manifest" "customresourcedefinition_ogmiosports_demeter_run
"spec" = {
"properties" = {
"network" = {
"enum" = [
"mainnet",
"preprod",
"preview",
"sanchonet",
]
"type" = "string"
}
"throughputTier" = {
Expand Down
12 changes: 6 additions & 6 deletions operator/src/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ use serde::{Deserialize, Serialize};
use std::{sync::Arc, time::Duration};
use tracing::{error, info, instrument};

use crate::{
build_api_key, build_hostname, patch_resource_status, Error, Metrics, Network, Result, State,
};
use crate::{build_api_key, build_hostname, patch_resource_status, Error, Metrics, Result, State};

pub static OGMIOS_PORT_FINALIZER: &str = "ogmiosports.demeter.run";

Expand All @@ -20,6 +18,8 @@ pub static OGMIOS_PORT_FINALIZER: &str = "ogmiosports.demeter.run";
kind = "OgmiosPort",
group = "demeter.run",
version = "v1alpha1",
category = "demeter-port",
shortname = "opt",
namespaced
)]
#[kube(status = "OgmiosPortStatus")]
Expand All @@ -28,12 +28,12 @@ pub static OGMIOS_PORT_FINALIZER: &str = "ogmiosports.demeter.run";
{"name": "Version", "jsonPath": ".spec.version", "type": "number"},
{"name": "Endpoint URL", "jsonPath": ".status.endpointUrl", "type": "string"},
{"name": "Authenticated Endpoint URL", "jsonPath": ".status.authenticatedEndpointUrl", "type": "string"},
{"name": "Auth Token", "jsonPath": ".status.authToken", "type": "string"}
{"name": "Throughput Tier", "jsonPath":".spec.throughputTier", "type": "string"},
{"name": "Auth Token", "jsonPath": ".status.authToken", "type": "string"},
{"name": "Throughput Tier", "jsonPath":".spec.throughputTier", "type": "string"}
"#)]
#[serde(rename_all = "camelCase")]
pub struct OgmiosPortSpec {
pub network: Network,
pub network: String,
pub version: u8,
// throughput should be 0, 1, 2
pub throughput_tier: String,
Expand Down
2 changes: 1 addition & 1 deletion operator/src/crdgen.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use operator::controller;
use kube::CustomResourceExt;
use operator::controller;

fn main() {
print!(
Expand Down
26 changes: 0 additions & 26 deletions operator/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
use std::fmt::{self, Display, Formatter};

use prometheus::Registry;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use thiserror::Error;

pub use kube;
Expand Down Expand Up @@ -78,28 +74,6 @@ impl State {
}
}

#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema)]
pub enum Network {
#[serde(rename = "mainnet")]
Mainnet,
#[serde(rename = "preprod")]
Preprod,
#[serde(rename = "preview")]
Preview,
#[serde(rename = "sanchonet")]
Sanchonet,
}
impl Display for Network {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
match self {
Network::Mainnet => write!(f, "mainnet"),
Network::Preprod => write!(f, "preprod"),
Network::Preview => write!(f, "preview"),
Network::Sanchonet => write!(f, "sanchonet"),
}
}
}

pub type Result<T, E = Error> = std::result::Result<T, E>;

pub mod controller;
Expand Down
4 changes: 2 additions & 2 deletions operator/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use kube::{
};
use serde_json::json;

use crate::{get_config, Error, Network, OgmiosPort};
use crate::{get_config, Error, OgmiosPort};

pub async fn patch_resource_status(
client: Client,
Expand All @@ -27,7 +27,7 @@ pub async fn patch_resource_status(
Ok(())
}

pub fn build_hostname(network: &Network, version: &u8, key: &str) -> (String, String) {
pub fn build_hostname(network: &str, version: &u8, key: &str) -> (String, String) {
let config = get_config();
let extension_name = &config.extension_name;
let dns_zone = &config.dns_zone;
Expand Down
Loading