From beba05a56d9ef4b4fc6270e9637456a4a69609f8 Mon Sep 17 00:00:00 2001 From: Tamipes Date: Wed, 3 Jun 2026 11:47:22 +0200 Subject: [PATCH 1/2] feat: add `forgejo actions` yaml to auto build and push a container image --- .forgejo/workflows/build.yaml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .forgejo/workflows/build.yaml diff --git a/.forgejo/workflows/build.yaml b/.forgejo/workflows/build.yaml new file mode 100644 index 0000000..32e5622 --- /dev/null +++ b/.forgejo/workflows/build.yaml @@ -0,0 +1,21 @@ +on: + push: + branches: + - main +jobs: + build: + runs-on: [ nix ] + steps: + - uses: actions/checkout@v4 + - name: Nix build + run: nix build --extra-experimental-features "flakes nix-command" .#docker-image + - name: Setup skopeo + run: curl -o /etc/containers/policy.json --create-dirs https://raw.githubusercontent.com/containers/skopeo/refs/heads/main/default-policy.json + - name: Push Image + run: | + skopeo copy --dest-password "$UPLOAD_TOKEN" --dest-username "$USERNAME" "docker-archive://$(realpath result)" "docker://$IMG_URL:${{ github.sha }}" && \ + skopeo copy --dest-password "$UPLOAD_TOKEN" --dest-username "$USERNAME" "docker-archive://$(realpath result)" "docker://$IMG_URL" + env: + USERNAME: tamipes + UPLOAD_TOKEN: ${{ secrets.UPLOAD_TOKEN }} + IMG_URL: git.tami.moe/tamipes/minecraft-ingress From b5f9c5e81cbc291db30a83ee662eea46fbd329a7 Mon Sep 17 00:00:00 2001 From: Tamipes Date: Wed, 3 Jun 2026 13:23:37 +0200 Subject: [PATCH 2/2] fix: could not initilaize `kube-rs` inside cluster, should infer config now --- src/kube_cache.rs | 9 ++++----- src/main.rs | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/kube_cache.rs b/src/kube_cache.rs index c8be2e5..ea76a90 100644 --- a/src/kube_cache.rs +++ b/src/kube_cache.rs @@ -29,9 +29,8 @@ pub struct KubeCache { impl KubeCache { /// This initializes the creation of a "kubernetes client" /// and if it is not possible returns a None. - pub fn create() -> Option { - let kubeconfig = kube::config::Kubeconfig::read().unwrap(); - let client = Client::try_from(kubeconfig).unwrap(); + pub async fn create() -> Option { + let client = Client::try_default().await.unwrap(); let deployments: Api = Api::default_namespaced(client.clone()); let services: Api = Api::default_namespaced(client); @@ -209,9 +208,9 @@ impl MinecraftAPI for McApi { } impl McApi { - pub fn create() -> Option { + pub async fn create() -> Option { Some(Self { - cache: KubeCache::create()?, + cache: KubeCache::create().await?, map: Arc::new(tokio::sync::Mutex::new(HashMap::new())), }) } diff --git a/src/main.rs b/src/main.rs index 80c5a3c..044cbc9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -39,7 +39,7 @@ async fn main() { let revision: &'static str = env!("COMMIT_HASH"); tracing::info!(revision); - let api = kube_cache::McApi::create().unwrap(); + let api = kube_cache::McApi::create().await.unwrap(); tracing::info!("initialized kube api"); let config: Config = Default::default();