diff --git a/changelog.d/+fixed-missing-http-dep.internal.md b/changelog.d/+fixed-missing-http-dep.internal.md new file mode 100644 index 00000000000..96d0e5e123b --- /dev/null +++ b/changelog.d/+fixed-missing-http-dep.internal.md @@ -0,0 +1 @@ +Fixed compilation of `mirrord-operator` crate with no features. \ No newline at end of file diff --git a/mirrord/operator/src/client.rs b/mirrord/operator/src/client.rs index 91ff07d4f43..b6da7c9b7e6 100644 --- a/mirrord/operator/src/client.rs +++ b/mirrord/operator/src/client.rs @@ -4,7 +4,7 @@ use base64::{engine::general_purpose, Engine}; use chrono::{DateTime, Utc}; use conn_wrapper::ConnectionWrapper; use error::{OperatorApiError, OperatorApiResult, OperatorOperation}; -use http::{request::Request, HeaderValue}; +use http::{request::Request, HeaderName, HeaderValue}; use kube::{ api::{ListParams, PostParams}, Api, Client, Config, Resource, @@ -387,7 +387,9 @@ impl OperatorApi { let header = Self::make_client_cert_header(&certificate)?; let mut config = self.client_cert.base_config; - config.headers.push((CLIENT_CERT_HEADER.clone(), header)); + config + .headers + .push((HeaderName::from_static(CLIENT_CERT_HEADER), header)); let client = Client::try_from(config) .map_err(KubeApiError::from) .map_err(OperatorApiError::CreateKubeClient)?; @@ -546,15 +548,15 @@ where .map_err(OperatorApiError::CreateKubeClient)?; client_config.headers.push(( - MIRRORD_CLI_VERSION_HEADER.clone(), + HeaderName::from_static(MIRRORD_CLI_VERSION_HEADER), HeaderValue::from_static(env!("CARGO_PKG_VERSION")), )); let UserIdentity { name, hostname } = UserIdentity::load(); let headers = [ - (CLIENT_NAME_HEADER.clone(), name), - (CLIENT_HOSTNAME_HEADER.clone(), hostname), + (CLIENT_NAME_HEADER, name), + (CLIENT_HOSTNAME_HEADER, hostname), ]; for (name, raw_value) in headers { let Some(raw_value) = raw_value else { @@ -568,7 +570,9 @@ where .to_string(); let value = HeaderValue::from_str(&cleaned); match value { - Ok(value) => client_config.headers.push((name, value)), + Ok(value) => client_config + .headers + .push((HeaderName::from_static(name), value)), Err(error) => { tracing::debug!(%error, %name, raw_value = raw_value, cleaned, "Invalid header value"); } @@ -799,7 +803,7 @@ impl OperatorApi { let cert_header = Self::make_client_cert_header(&session.client_cert)?; config .headers - .push((CLIENT_CERT_HEADER.clone(), cert_header)); + .push((HeaderName::from_static(CLIENT_CERT_HEADER), cert_header)); let client = Client::try_from(config) .map_err(KubeApiError::from) @@ -818,7 +822,7 @@ impl OperatorApi { ) -> OperatorApiResult<(Sender, Receiver)> { let request = Request::builder() .uri(&session.connect_url) - .header(SESSION_ID_HEADER.clone(), session.id.to_string()) + .header(SESSION_ID_HEADER, session.id.to_string()) .body(vec![]) .map_err(OperatorApiError::ConnectRequestBuildError)?; diff --git a/mirrord/operator/src/types.rs b/mirrord/operator/src/types.rs index bf64320da85..78107221307 100644 --- a/mirrord/operator/src/types.rs +++ b/mirrord/operator/src/types.rs @@ -1,5 +1,4 @@ use chrono::NaiveDate; -use http::HeaderName; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -14,26 +13,25 @@ pub struct LicenseInfoOwned { pub subscription_id: Option, } -/// HTTP header containing CLI version. +/// Name of HTTP header containing CLI version. /// Sent with each request to the mirrord operator. -pub static MIRRORD_CLI_VERSION_HEADER: HeaderName = - HeaderName::from_static("x-mirrord-cli-version"); +pub const MIRRORD_CLI_VERSION_HEADER: &str = "x-mirrord-cli-version"; -/// HTTP header containing client certificate. +/// Name of HTTP header containing client certificate. /// Sent with each request to the mirrord operator (if available) except: /// 1. Initial GET on the operator resource /// 2. User certificate request /// Required for making the target connection request. -pub static CLIENT_CERT_HEADER: HeaderName = HeaderName::from_static("x-client-der"); +pub const CLIENT_CERT_HEADER: &str = "x-client-der"; -/// HTTP header containing client hostname. +/// Name of HTTP header containing client hostname. /// Sent with each request to the mirrord operator (if available). -pub static CLIENT_HOSTNAME_HEADER: HeaderName = HeaderName::from_static("x-client-hostname"); +pub const CLIENT_HOSTNAME_HEADER: &str = "x-client-hostname"; -/// HTTP header containing client name. +/// Name of HTTP header containing client name. /// Sent with each request to the mirrord operator (if available). -pub static CLIENT_NAME_HEADER: HeaderName = HeaderName::from_static("x-client-name"); +pub const CLIENT_NAME_HEADER: &str = "x-client-name"; -/// HTTP header containing operator session id. +/// Name of HTTP header containing operator session id. /// Sent with target connection request. -pub static SESSION_ID_HEADER: HeaderName = HeaderName::from_static("x-session-id"); +pub const SESSION_ID_HEADER: &str = "x-session-id";