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
91 changes: 91 additions & 0 deletions src/grid_client/deployment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,32 @@ fn workload_challenge(out: &mut String, workload: &DeployWorkload) -> Result<(),
out.push_str(&gpu);
}
}
zos::GATEWAY_NAME_PROXY_TYPE => {
// Matches the canonical Go ZOS implementation in
// pkg/gridtypes/zos/gw_name.go: Name → TLSPassthrough → Backends.
// `network` is NOT included in the challenge — ZOS rejects the
// signature otherwise.
let data: GatewayNameProxyData =
serde_json::from_value(workload.data.clone()).map_err(GridError::from)?;
out.push_str(&data.name);
write!(out, "{}", data.tls_passthrough)
.map_err(|err| GridError::backend(err.to_string()))?;
for backend in &data.backends {
out.push_str(backend);
}
}
zos::GATEWAY_FQDN_PROXY_TYPE => {
// Matches the canonical Go ZOS implementation in
// pkg/gridtypes/zos/gw_fqdn.go: FQDN → TLSPassthrough → Backends.
let data: GatewayFqdnProxyData =
serde_json::from_value(workload.data.clone()).map_err(GridError::from)?;
out.push_str(&data.fqdn);
write!(out, "{}", data.tls_passthrough)
.map_err(|err| GridError::backend(err.to_string()))?;
for backend in &data.backends {
out.push_str(backend);
}
}
other => {
return Err(GridError::validation(format!(
"unsupported live workload type {other}"
Expand All @@ -720,6 +746,71 @@ pub(crate) fn public_ip_count(workloads: &[DeployWorkload]) -> u32 {
.count() as u32
}

#[derive(Debug, Clone, Serialize, Deserialize)]
struct GatewayNameProxyData {
name: String,
tls_passthrough: bool,
backends: Vec<String>,
#[serde(skip_serializing_if = "String::is_empty", default)]
network: String,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
struct GatewayFqdnProxyData {
fqdn: String,
tls_passthrough: bool,
backends: Vec<String>,
#[serde(skip_serializing_if = "String::is_empty", default)]
network: String,
}

pub(crate) fn build_gateway_name_proxy(
name: &str,
backends: &[String],
tls_passthrough: bool,
network: Option<&str>,
) -> DeployWorkload {
DeployWorkload {
version: 0,
name: name.to_string(),
workload_type: zos::GATEWAY_NAME_PROXY_TYPE.to_string(),
data: serde_json::to_value(GatewayNameProxyData {
name: name.to_string(),
tls_passthrough,
backends: backends.to_vec(),
network: network.unwrap_or("").to_string(),
})
.unwrap_or_default(),
metadata: String::new(),
description: "gateway-name-proxy".to_string(),
result: empty_result_data(),
}
}

pub(crate) fn build_gateway_fqdn_proxy(
name: &str,
fqdn: &str,
backends: &[String],
tls_passthrough: bool,
network: Option<&str>,
) -> DeployWorkload {
DeployWorkload {
version: 0,
name: name.to_string(),
workload_type: zos::GATEWAY_FQDN_PROXY_TYPE.to_string(),
data: serde_json::to_value(GatewayFqdnProxyData {
fqdn: fqdn.to_string(),
tls_passthrough,
backends: backends.to_vec(),
network: network.unwrap_or("").to_string(),
})
.unwrap_or_default(),
metadata: String::new(),
description: "gateway-fqdn-proxy".to_string(),
result: empty_result_data(),
}
}

pub(crate) fn empty_result_data() -> zos::ResultData {
zos::ResultData {
created: 0,
Expand Down
Loading
Loading