From f0a719e3ed3d281f14c3e04a5d44f5506fc07a60 Mon Sep 17 00:00:00 2001 From: kjuulh Date: Wed, 31 Jan 2024 21:16:48 +0100 Subject: [PATCH] feat: with kubeslice Signed-off-by: kjuulh --- crates/cuddle-ci/src/rust_service/kubectl.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/crates/cuddle-ci/src/rust_service/kubectl.rs b/crates/cuddle-ci/src/rust_service/kubectl.rs index c61b8aa..4081cd9 100644 --- a/crates/cuddle-ci/src/rust_service/kubectl.rs +++ b/crates/cuddle-ci/src/rust_service/kubectl.rs @@ -1,7 +1,7 @@ use std::sync::Arc; use async_trait::async_trait; -use dagger_sdk::{Container, ImageMediaTypes}; +use dagger_sdk::Container; use crate::dagger_middleware::DaggerMiddleware; @@ -17,6 +17,13 @@ impl Kubectl { } } +const KUBESLICEDOWNLOAD: &str = r#"slice_VERSION=v1.2.7 && \ +wget -O kubectl-slice_linux_x86_64.tar.gz "https://github.com/patrickdappollonio/kubectl-slice/releases/download/$slice_VERSION/kubectl-slice_linux_x86_64.tar.gz" && \ +tar -xf kubectl-slice_linux_x86_64.tar.gz && \ +chmod +x ./kubectl-slice && \ +mv ./kubectl-slice /usr/local/bin/kubectl-slice && \ +rm kubectl-slice_linux_x86_64.tar.gz"#; + #[async_trait] impl DaggerMiddleware for Kubectl { async fn handle(&self, container: Container) -> eyre::Result { @@ -25,6 +32,13 @@ impl DaggerMiddleware for Kubectl { .container() .from("line/kubectl-kustomize:1.29.1-5.3.0"); + let kubeslice = self + .client + .container() + .from("alpine:3.19") + .with_exec(vec!["apk", "add", "tar", "wget"]) + .with_exec(vec!["sh", "-c", KUBESLICEDOWNLOAD]); + Ok(container .with_file( "/usr/local/bin/kubectl", @@ -33,6 +47,10 @@ impl DaggerMiddleware for Kubectl { .with_file( "/usr/local/bin/kustomize", kubectl.file("/usr/local/bin/kustomize"), + ) + .with_file( + "/usr/local/bin/kubectl-slice", + kubeslice.file("kubectl-slice"), )) } }