Skip to content

Commit 53f6c59

Browse files
fix: Remove enum options for network on CRD (#32)
1 parent bd86f1e commit 53f6c59

File tree

5 files changed

+9
-41
lines changed

5 files changed

+9
-41
lines changed

Diff for: bootstrap/crds/main.tf

-6
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,6 @@ resource "kubernetes_manifest" "customresourcedefinition_ogmiosports_demeter_run
6161
"spec" = {
6262
"properties" = {
6363
"network" = {
64-
"enum" = [
65-
"mainnet",
66-
"preprod",
67-
"preview",
68-
"sanchonet",
69-
]
7064
"type" = "string"
7165
}
7266
"throughputTier" = {

Diff for: operator/src/controller.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ use serde::{Deserialize, Serialize};
99
use std::{sync::Arc, time::Duration};
1010
use tracing::{error, info, instrument};
1111

12-
use crate::{
13-
build_api_key, build_hostname, patch_resource_status, Error, Metrics, Network, Result, State,
14-
};
12+
use crate::{build_api_key, build_hostname, patch_resource_status, Error, Metrics, Result, State};
1513

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

@@ -20,6 +18,8 @@ pub static OGMIOS_PORT_FINALIZER: &str = "ogmiosports.demeter.run";
2018
kind = "OgmiosPort",
2119
group = "demeter.run",
2220
version = "v1alpha1",
21+
category = "demeter-port",
22+
shortname = "opt",
2323
namespaced
2424
)]
2525
#[kube(status = "OgmiosPortStatus")]
@@ -28,12 +28,12 @@ pub static OGMIOS_PORT_FINALIZER: &str = "ogmiosports.demeter.run";
2828
{"name": "Version", "jsonPath": ".spec.version", "type": "number"},
2929
{"name": "Endpoint URL", "jsonPath": ".status.endpointUrl", "type": "string"},
3030
{"name": "Authenticated Endpoint URL", "jsonPath": ".status.authenticatedEndpointUrl", "type": "string"},
31-
{"name": "Auth Token", "jsonPath": ".status.authToken", "type": "string"}
32-
{"name": "Throughput Tier", "jsonPath":".spec.throughputTier", "type": "string"},
31+
{"name": "Auth Token", "jsonPath": ".status.authToken", "type": "string"},
32+
{"name": "Throughput Tier", "jsonPath":".spec.throughputTier", "type": "string"}
3333
"#)]
3434
#[serde(rename_all = "camelCase")]
3535
pub struct OgmiosPortSpec {
36-
pub network: Network,
36+
pub network: String,
3737
pub version: u8,
3838
// throughput should be 0, 1, 2
3939
pub throughput_tier: String,

Diff for: operator/src/crdgen.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use operator::controller;
21
use kube::CustomResourceExt;
2+
use operator::controller;
33

44
fn main() {
55
print!(

Diff for: operator/src/lib.rs

-26
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
use std::fmt::{self, Display, Formatter};
2-
31
use prometheus::Registry;
4-
use schemars::JsonSchema;
5-
use serde::{Deserialize, Serialize};
62
use thiserror::Error;
73

84
pub use kube;
@@ -78,28 +74,6 @@ impl State {
7874
}
7975
}
8076

81-
#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema)]
82-
pub enum Network {
83-
#[serde(rename = "mainnet")]
84-
Mainnet,
85-
#[serde(rename = "preprod")]
86-
Preprod,
87-
#[serde(rename = "preview")]
88-
Preview,
89-
#[serde(rename = "sanchonet")]
90-
Sanchonet,
91-
}
92-
impl Display for Network {
93-
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
94-
match self {
95-
Network::Mainnet => write!(f, "mainnet"),
96-
Network::Preprod => write!(f, "preprod"),
97-
Network::Preview => write!(f, "preview"),
98-
Network::Sanchonet => write!(f, "sanchonet"),
99-
}
100-
}
101-
}
102-
10377
pub type Result<T, E = Error> = std::result::Result<T, E>;
10478

10579
pub mod controller;

Diff for: operator/src/utils.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use kube::{
99
};
1010
use serde_json::json;
1111

12-
use crate::{get_config, Error, Network, OgmiosPort};
12+
use crate::{get_config, Error, OgmiosPort};
1313

1414
pub async fn patch_resource_status(
1515
client: Client,
@@ -27,7 +27,7 @@ pub async fn patch_resource_status(
2727
Ok(())
2828
}
2929

30-
pub fn build_hostname(network: &Network, version: &u8, key: &str) -> (String, String) {
30+
pub fn build_hostname(network: &str, version: &u8, key: &str) -> (String, String) {
3131
let config = get_config();
3232
let extension_name = &config.extension_name;
3333
let dns_zone = &config.dns_zone;

0 commit comments

Comments
 (0)