[go: nahoru, domu]

Skip to content

Commit

Permalink
kubelet/container: use borrowed inner types
Browse files Browse the repository at this point in the history
Signed-off-by: Olivier Lemasle <olivier.lemasle@apalia.net>
  • Loading branch information
olivierlemasle committed Oct 1, 2021
1 parent ed2efa9 commit 10871b0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
28 changes: 14 additions & 14 deletions crates/kubelet/src/container/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,23 +138,23 @@ impl Container {
}

/// Get arguments of container.
pub fn args(&self) -> &Option<Vec<String>> {
&self.0.args
pub fn args(&self) -> Option<&Vec<String>> {
self.0.args.as_ref()
}

/// Get command of container.
pub fn command(&self) -> &Option<Vec<String>> {
&self.0.command
pub fn command(&self) -> Option<&Vec<String>> {
self.0.command.as_ref()
}

/// Get environment of container.
pub fn env(&self) -> &Option<Vec<k8s_openapi::api::core::v1::EnvVar>> {
&self.0.env
pub fn env(&self) -> Option<&Vec<k8s_openapi::api::core::v1::EnvVar>> {
self.0.env.as_ref()
}

/// Get environment of container.
pub fn env_from(&self) -> &Option<Vec<k8s_openapi::api::core::v1::EnvFromSource>> {
&self.0.env_from
pub fn env_from(&self) -> Option<&Vec<k8s_openapi::api::core::v1::EnvFromSource>> {
self.0.env_from.as_ref()
}

/// Get image of container as `oci_distribution::Reference`.
Expand Down Expand Up @@ -186,8 +186,8 @@ impl Container {
}

/// Get ports of container.
pub fn ports(&self) -> &Option<Vec<k8s_openapi::api::core::v1::ContainerPort>> {
&self.0.ports
pub fn ports(&self) -> Option<&Vec<k8s_openapi::api::core::v1::ContainerPort>> {
self.0.ports.as_ref()
}

/// Get readiness probe of container.
Expand Down Expand Up @@ -236,13 +236,13 @@ impl Container {
}

/// Get volume devices of container.
pub fn volume_devices(&self) -> &Option<Vec<k8s_openapi::api::core::v1::VolumeDevice>> {
&self.0.volume_devices
pub fn volume_devices(&self) -> Option<&Vec<k8s_openapi::api::core::v1::VolumeDevice>> {
self.0.volume_devices.as_ref()
}

/// Get volume mounts of container.
pub fn volume_mounts(&self) -> &Option<Vec<k8s_openapi::api::core::v1::VolumeMount>> {
&self.0.volume_mounts
pub fn volume_mounts(&self) -> Option<&Vec<k8s_openapi::api::core::v1::VolumeMount>> {
self.0.volume_mounts.as_ref()
}

/// Get working directory of container.
Expand Down
4 changes: 2 additions & 2 deletions crates/kubelet/src/provider/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ pub trait Provider: Sized + Send + Sync + 'static {
client: &kube::Client,
) -> HashMap<String, String> {
let mut env = HashMap::new();
let vars = match container.env().as_ref() {
let vars = match container.env() {
Some(e) => e,
None => return env,
};
Expand Down Expand Up @@ -231,7 +231,7 @@ pub async fn env_vars(
client: &kube::Client,
) -> HashMap<String, String> {
let mut env = HashMap::new();
let vars = match container.env().as_ref() {
let vars = match container.env() {
Some(e) => e,
None => return env,
};
Expand Down
2 changes: 1 addition & 1 deletion crates/wasi-provider/src/states/container/waiting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ impl State<ContainerState> for Waiting {

let mut env = kubelet::provider::env_vars(&container, &state.pod, &client).await;
env.extend(container_envs);
let args = container.args().clone().unwrap_or_default();
let args: Vec<String> = container.args().map(|t| t.clone()).unwrap_or_default();

// TODO: ~magic~ number
let (tx, rx) = mpsc::channel(8);
Expand Down

0 comments on commit 10871b0

Please sign in to comment.