55 lines
1.2 KiB
Rust
55 lines
1.2 KiB
Rust
|
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
|
||
|
}
|
||
|
}
|