feat: add kubectl command
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
parent
c16396db8c
commit
91ff1f17ae
@ -420,6 +420,7 @@ mod clap_sanity_test;
|
|||||||
mod cuddle_cli;
|
mod cuddle_cli;
|
||||||
mod docker_cache;
|
mod docker_cache;
|
||||||
mod docker_cli;
|
mod docker_cli;
|
||||||
|
mod kubectl;
|
||||||
mod mold;
|
mod mold;
|
||||||
mod sqlx;
|
mod sqlx;
|
||||||
mod ssh_agent;
|
mod ssh_agent;
|
||||||
@ -434,6 +435,7 @@ pub mod extensions {
|
|||||||
pub use super::cuddle_cli::*;
|
pub use super::cuddle_cli::*;
|
||||||
pub use super::docker_cache::*;
|
pub use super::docker_cache::*;
|
||||||
pub use super::docker_cli::*;
|
pub use super::docker_cli::*;
|
||||||
|
pub use super::kubectl::*;
|
||||||
pub use super::mold::*;
|
pub use super::mold::*;
|
||||||
pub use super::sqlx::*;
|
pub use super::sqlx::*;
|
||||||
pub use super::ssh_agent::*;
|
pub use super::ssh_agent::*;
|
||||||
|
54
crates/cuddle-ci/src/rust_service/kubectl.rs
Normal file
54
crates/cuddle-ci/src/rust_service/kubectl.rs
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
use async_trait::async_trait;
|
||||||
|
use dagger_sdk::{Container, ImageMediaTypes};
|
||||||
|
|
||||||
|
use crate::dagger_middleware::DaggerMiddleware;
|
||||||
|
|
||||||
|
use super::RustService;
|
||||||
|
|
||||||
|
pub struct Kubectl {
|
||||||
|
client: dagger_sdk::Query,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Kubectl {
|
||||||
|
pub fn new(client: dagger_sdk::Query) -> Self {
|
||||||
|
Self { client }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[async_trait]
|
||||||
|
impl DaggerMiddleware for Kubectl {
|
||||||
|
async fn handle(&self, container: Container) -> eyre::Result<Container> {
|
||||||
|
let kubectl = self
|
||||||
|
.client
|
||||||
|
.container()
|
||||||
|
.from("line/kubectl-kustomize:1.29.1-5.3.0");
|
||||||
|
|
||||||
|
Ok(container
|
||||||
|
.with_file(
|
||||||
|
"/usr/local/bin/kubectl",
|
||||||
|
kubectl.file("/usr/local/bin/kubectl"),
|
||||||
|
)
|
||||||
|
.with_file(
|
||||||
|
"/usr/local/bin/kustomize",
|
||||||
|
kubectl.file("/usr/local/bin/kustomize"),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait KubectlExt {
|
||||||
|
fn with_kubectl(&mut self) -> &mut Self {
|
||||||
|
self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl KubectlExt for RustService {
|
||||||
|
fn with_kubectl(&mut self) -> &mut Self {
|
||||||
|
self.with_stage(super::RustServiceStage::BeforePackage(Arc::new(
|
||||||
|
Kubectl::new(self.client.clone()),
|
||||||
|
)));
|
||||||
|
|
||||||
|
self
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user