Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
hanneary committed Dec 11, 2023
1 parent 59f88f0 commit f621cff
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/api/assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl ApiClient for AssetsClient {

fn base_url(&self) -> String {
let domain = std::env::var("EV_DOMAIN").unwrap_or_else(|_| String::from("evervault.com"));
format!("https://cage-build-assets.{}", domain)
format!("https://enclave-build-assets.{}", domain)
}

fn auth(&self) -> &super::AuthMode {
Expand Down
1 change: 0 additions & 1 deletion src/api/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ pub trait HandleResponse {
#[async_trait]
impl HandleResponse for ReqwestResult<Response> {
async fn handle_json_response<T: DeserializeOwned>(self) -> ApiResult<T> {
println!("self: {:?}", self);
match self {
Ok(res) if res.status().is_success() => res
.json()
Expand Down
34 changes: 17 additions & 17 deletions src/api/enclave.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ impl CreateEnclaveRequest {
#[serde(rename_all = "camelCase")]
pub struct CreateEnclaveDeploymentIntentResponse {
signed_url: String,
uuid: String,
enclave_uuid: String,
deployment_uuid: String,
version: u32,
}
Expand All @@ -461,7 +461,7 @@ impl CreateEnclaveDeploymentIntentResponse {
}

pub fn enclave_uuid(&self) -> &str {
&self.uuid
&self.enclave_uuid
}

pub fn deployment_uuid(&self) -> &str {
Expand Down Expand Up @@ -752,14 +752,14 @@ impl GetEnclaveResponse {
pub struct GetEnclaveDeploymentResponse {
#[serde(flatten)]
pub deployment: EnclaveDeployment,
pub tee_enclave_version: EnclaveVersion,
pub tee_enclave_signing_cert: EnclaveSigningCert,
pub tee_enclave_regional_deployments: Vec<EnclaveRegionalDeployment>,
pub enclave_version: EnclaveVersion,
pub enclave_signing_cert: EnclaveSigningCert,
pub enclave_regional_deployments: Vec<EnclaveRegionalDeployment>,
}

impl GetEnclaveDeploymentResponse {
pub fn is_built(&self) -> bool {
matches!(self.tee_enclave_version.build_status, BuildStatus::Ready)
matches!(self.enclave_version.build_status, BuildStatus::Ready)
}

pub fn is_finished(&self) -> bool {
Expand All @@ -768,25 +768,25 @@ impl GetEnclaveDeploymentResponse {

//TODO: Handle multi region deployment failures
pub fn is_failed(&self) -> bool {
let build_failed = matches!(self.tee_enclave_version.build_status, BuildStatus::Failed);
let build_failed = matches!(self.enclave_version.build_status, BuildStatus::Failed);
build_failed
|| self
.tee_enclave_regional_deployments
.enclave_regional_deployments
.first()
.map(|depl| depl.is_failed())
.unwrap_or_default()
}

pub fn get_failure_reason(&self) -> Option<String> {
self.tee_enclave_version.failure_reason.clone().or_else(|| {
self.tee_enclave_regional_deployments
self.enclave_version.failure_reason.clone().or_else(|| {
self.enclave_regional_deployments
.first()
.map(|depl| depl.get_failure_reason())
})
}

pub fn get_detailed_status(&self) -> Option<String> {
self.tee_enclave_regional_deployments
self.enclave_regional_deployments
.first()
.map(|depl| depl.get_detailed_status())
}
Expand Down Expand Up @@ -937,9 +937,9 @@ mod test {
let cert = get_testing_cert();
let deployment_with_empty_regional = GetEnclaveDeploymentResponse {
deployment,
tee_enclave_version: version,
tee_enclave_signing_cert: cert,
tee_enclave_regional_deployments: vec![],
enclave_version: version,
enclave_signing_cert: cert,
enclave_regional_deployments: vec![],
};

assert!(deployment_with_empty_regional
Expand All @@ -961,9 +961,9 @@ mod test {
let detailed_failure_reason = "Insufficient capacity".to_string();
let deployment_with_regional = GetEnclaveDeploymentResponse {
deployment,
tee_enclave_version: version,
tee_enclave_signing_cert: cert,
tee_enclave_regional_deployments: vec![EnclaveRegionalDeployment {
enclave_version: version,
enclave_signing_cert: cert,
enclave_regional_deployments: vec![EnclaveRegionalDeployment {
uuid: "abc".to_string(),
deployment_uuid: "def".to_string(),
deployment_order: 1,
Expand Down
1 change: 1 addition & 0 deletions src/cli/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ pub async fn run(deploy_args: DeployArgs) -> exitcode::ExitCode {
enclave_config.set_attestation(&eif_measurements);
crate::common::save_enclave_config(&enclave_config, &deploy_args.config);

println!("Deploying enclave");
if let Err(e) = deploy_eif(
&validated_config,
enclave_api,
Expand Down
6 changes: 3 additions & 3 deletions src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ pub fn build_get_enclave_deployment(
started_at: started_at.clone(),
completed_at: completed_at.clone(),
},
tee_enclave_version: EnclaveVersion {
enclave_version: EnclaveVersion {
uuid: "".into(),
version: 0,
control_plane_img_url: Some("".into()),
Expand All @@ -92,15 +92,15 @@ pub fn build_get_enclave_deployment(
started_at: started_at.clone(),
healthcheck: None,
},
tee_enclave_signing_cert: EnclaveSigningCert {
enclave_signing_cert: EnclaveSigningCert {
name: Some("".into()),
uuid: "".into(),
app_uuid: "".into(),
cert_hash: "".into(),
not_before: None,
not_after: None,
},
tee_enclave_regional_deployments: vec![EnclaveRegionalDeployment {
enclave_regional_deployments: vec![EnclaveRegionalDeployment {
uuid: "".into(),
deployment_uuid: "".into(),
deployment_order: 0,
Expand Down

0 comments on commit f621cff

Please sign in to comment.