Skip to content

Commit

Permalink
Port shim layer to v2 (#558)
Browse files Browse the repository at this point in the history
Signed-off-by: Xudong Sun <[email protected]>
  • Loading branch information
marshtompsxd authored Oct 4, 2024
1 parent 55aead4 commit 701a508
Show file tree
Hide file tree
Showing 12 changed files with 569 additions and 31 deletions.
5 changes: 0 additions & 5 deletions src/anvil_v2.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// Copyright 2022 VMware, Inc.
// SPDX-License-Identifier: MIT

#![allow(unused_imports)]

pub mod external_api;
pub mod kubernetes_api_objects;
#[path = "v2/kubernetes_cluster/mod.rs"]
pub mod kubernetes_cluster;
Expand All @@ -12,5 +9,3 @@ pub mod reconciler;
pub mod state_machine;
pub mod temporal_logic;
pub mod vstd_ext;

use vstd::prelude::*;
23 changes: 23 additions & 0 deletions src/v2/external_shim_layer/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright 2022 VMware, Inc.
// SPDX-License-Identifier: MIT
use crate::reconciler::exec::io::{VoidEReq, VoidEResp};

// A trait for the external api of a reconciler, whose core is a transition method, and the developer should wrap all
// possible operations they may need in the function.
// Input is the input type of the external api and also the ? of Request<?> of the reconciler, i.e., it completes the
// request type of a reconciler.
// Similarly, Output is the output type of the external api, which composes the Response<?> type of a reconciler.
// Note that we can encapsulate all the required libraries here, so each reconciler only has one ExternalAPI type.
pub trait ExternalShimLayer<EReq, EResp> {
fn external_call(req: EReq) -> EResp;
}

// An empty library that implements External Library.
// This can be used by those controllers that don't rely on a third-party library.
pub struct VoidExternalShimLayer {}

impl ExternalShimLayer<VoidEReq, VoidEResp> for VoidExternalShimLayer {
fn external_call(_input: VoidEReq) -> VoidEResp {
panic!("This should not be visited");
}
}
1 change: 0 additions & 1 deletion src/v2/kubernetes_cluster/spec/api_server/state_machine.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright 2022 VMware, Inc.
// SPDX-License-Identifier: MIT
#![allow(unused_imports)]
use crate::external_api::spec::*;
use crate::kubernetes_api_objects::error::*;
use crate::kubernetes_api_objects::spec::prelude::*;
use crate::kubernetes_cluster::spec::{api_server::types::*, message::*};
Expand Down
3 changes: 1 addition & 2 deletions src/v2/kubernetes_cluster/spec/api_server/types.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
// Copyright 2022 VMware, Inc.
// SPDX-License-Identifier: MIT
#![allow(unused_imports)]
use crate::external_api::spec::*;
use crate::kubernetes_api_objects::spec::prelude::*;
use crate::kubernetes_cluster::spec::message::*;
use crate::state_machine::action::*;
use crate::state_machine::state_machine::*;
use crate::temporal_logic::defs::*;
use crate::kubernetes_cluster::spec::message::*;
use crate::vstd_ext::string_view::StringView;
use vstd::{multiset::*, prelude::*};

Expand Down
3 changes: 1 addition & 2 deletions src/v2/kubernetes_cluster/spec/controller/types.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
// Copyright 2022 VMware, Inc.
// SPDX-License-Identifier: MIT
#![allow(unused_imports)]
use crate::external_api::spec::*;
use crate::kubernetes_api_objects::spec::prelude::*;
use crate::kubernetes_cluster::spec::message::*;
use crate::state_machine::action::*;
use crate::state_machine::state_machine::*;
use crate::kubernetes_cluster::spec::message::*;
use vstd::{multiset::*, prelude::*};

verus! {
Expand Down
3 changes: 1 addition & 2 deletions src/v2/kubernetes_cluster/spec/external/types.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
// Copyright 2022 VMware, Inc.
// SPDX-License-Identifier: MIT
#![allow(unused_imports)]
use crate::external_api::spec::*;
use crate::kubernetes_api_objects::spec::prelude::*;
use crate::kubernetes_cluster::spec::message::*;
use crate::state_machine::action::*;
use crate::state_machine::state_machine::*;
use crate::kubernetes_cluster::spec::message::*;

use crate::temporal_logic::defs::*;
use vstd::{multiset::*, prelude::*};
Expand Down
1 change: 0 additions & 1 deletion src/v2/kubernetes_cluster/spec/message.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright 2022 VMware, Inc.
// SPDX-License-Identifier: MIT
#![allow(unused_imports)]
use crate::external_api::spec::*;
use crate::kubernetes_api_objects::error::*;
use crate::kubernetes_api_objects::spec::prelude::*;
use crate::vstd_ext::string_view::*;
Expand Down
1 change: 0 additions & 1 deletion src/v2/reconciler/exec/resource_builder.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright 2022 VMware, Inc.
// SPDX-License-Identifier: MIT
#![allow(unused_imports)]
use crate::external_api::exec::*;
use crate::kubernetes_api_objects::exec::{api_method::*, dynamic::*, resource::*};
use crate::reconciler::exec::{io::*, reconciler::*};
use crate::reconciler::spec::resource_builder;
Expand Down
Loading

0 comments on commit 701a508

Please sign in to comment.