Skip to content

Commit eab1405

Browse files
authored
Add fields and methods to ServicePort and ContainerPort (anvil-verifier#434)
Add more fields, their setter and getter methods to `ServicePort` and `ContainerPort`. --------- Signed-off-by: Wenjie Ma <[email protected]>
1 parent df7021d commit eab1405

File tree

5 files changed

+55
-3
lines changed

5 files changed

+55
-3
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
source ../tools/activate
3535
vargo build --release
3636
- name: Verify fluent controller
37-
run: VERUS_DIR="$(dirname "${PWD}")/verus" ./build.sh fluent_controller.rs --time
37+
run: VERUS_DIR="$(dirname "${PWD}")/verus" ./build.sh fluent_controller.rs --time --rlimit 20
3838
rabbitmq-verification:
3939
runs-on: ubuntu-20.04
4040
steps:
@@ -57,7 +57,7 @@ jobs:
5757
source ../tools/activate
5858
vargo build --release
5959
- name: Verify rabbitmq controller
60-
run: VERUS_DIR="$(dirname "${PWD}")/verus" ./build.sh rabbitmq_controller.rs --time
60+
run: VERUS_DIR="$(dirname "${PWD}")/verus" ./build.sh rabbitmq_controller.rs --time --rlimit 20
6161
zookeeper-verification:
6262
runs-on: ubuntu-20.04
6363
steps:
@@ -80,7 +80,7 @@ jobs:
8080
source ../tools/activate
8181
vargo build --release
8282
- name: Verify zookeeper controller
83-
run: VERUS_DIR="$(dirname "${PWD}")/verus" ./build.sh zookeeper_controller.rs --time
83+
run: VERUS_DIR="$(dirname "${PWD}")/verus" ./build.sh zookeeper_controller.rs --time --rlimit 20
8484
unit-tests:
8585
runs-on: ubuntu-20.04
8686
steps:

src/kubernetes_api_objects/exec/container.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,33 @@ impl ContainerPort {
185185
self.inner.name = Some(name.into_rust_string());
186186
}
187187

188+
#[verifier(external_body)]
189+
pub fn name(&self) -> (name: Option<String>)
190+
ensures opt_string_to_view(&name) == self@.name,
191+
{
192+
match &self.inner.name {
193+
Some(s) => Some(String::from_rust_string(s.clone())),
194+
None => None,
195+
}
196+
}
197+
198+
#[verifier(external_body)]
199+
pub fn container_port(&self) -> (container_port: i32)
200+
ensures container_port == self@.container_port,
201+
{
202+
self.inner.container_port
203+
}
204+
205+
#[verifier(external_body)]
206+
pub fn protocol(&self) -> (protocol: Option<String>)
207+
ensures opt_string_to_view(&protocol) == self@.protocol,
208+
{
209+
match &self.inner.protocol {
210+
Some(s) => Some(String::from_rust_string(s.clone())),
211+
None => None,
212+
}
213+
}
214+
188215
#[verifier(external)]
189216
pub fn from_kube(inner: deps_hack::k8s_openapi::api::core::v1::ContainerPort) -> ContainerPort { ContainerPort { inner: inner } }
190217

src/kubernetes_api_objects/exec/service.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,13 @@ impl ServicePort {
266266
self.inner.app_protocol = Some(app_protocol.into_rust_string());
267267
}
268268

269+
#[verifier(external_body)]
270+
pub fn set_protocol(&mut self, protocol: String)
271+
ensures self@ == old(self)@.set_protocol(protocol@),
272+
{
273+
self.inner.protocol = Some(protocol.into_rust_string());
274+
}
275+
269276
#[verifier(external)]
270277
pub fn from_kube(inner: deps_hack::k8s_openapi::api::core::v1::ServicePort) -> ServicePort { ServicePort { inner: inner } }
271278

src/kubernetes_api_objects/spec/container.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,13 +183,15 @@ impl LifecycleHandlerView {
183183
pub struct ContainerPortView {
184184
pub container_port: int,
185185
pub name: Option<StringView>,
186+
pub protocol: Option<StringView>,
186187
}
187188

188189
impl ContainerPortView {
189190
pub open spec fn default() -> ContainerPortView {
190191
ContainerPortView {
191192
container_port: 0, // TODO: is this the correct default value?
192193
name: None,
194+
protocol: None,
193195
}
194196
}
195197

@@ -206,6 +208,13 @@ impl ContainerPortView {
206208
..self
207209
}
208210
}
211+
212+
pub open spec fn set_protocol(self, protocol: StringView) -> ContainerPortView {
213+
ContainerPortView {
214+
protocol: Some(protocol),
215+
..self
216+
}
217+
}
209218
}
210219

211220
pub struct VolumeMountView {

src/kubernetes_api_objects/spec/service.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ pub struct ServicePortView {
192192
pub name: Option<StringView>,
193193
pub port: int,
194194
pub app_protocol: Option<StringView>,
195+
pub protocol: Option<StringView>,
195196
}
196197

197198
impl ServicePortView {
@@ -200,6 +201,7 @@ impl ServicePortView {
200201
name: None,
201202
port: 0, // TODO: is this the correct default value?
202203
app_protocol: None,
204+
protocol: None,
203205
}
204206
}
205207

@@ -223,6 +225,13 @@ impl ServicePortView {
223225
..self
224226
}
225227
}
228+
229+
pub open spec fn set_protocol(self, protocol: StringView) -> ServicePortView {
230+
ServicePortView {
231+
protocol: Some(protocol),
232+
..self
233+
}
234+
}
226235
}
227236

228237
}

0 commit comments

Comments
 (0)