Your browser sucks, JavaScript disabled! Gunnar's console needs JavaScript and WebAssembly. Git over SSH on port 2222 does not.

nordisk/gunnar-ui

crates/gunnar-ui-server/src/forges_off.rs

//! **Forge import, not built** (AIRGAP, owner rule 2026-10-25). Connecting github.com,
//! or a GitLab dials them, so the client (`gunnar-forge`, `ureq`) is only in a
//! build with the `forges` feature, and even there only with `GUNNAR_UI_FORGES=on`. This
//! stand-in keeps the names the rest of the console holds (the open console's actor name, the
//! two empty stores) and answers every forge door with one refusal that names the feature.

use crate::api::ApiError;
use crate::grpc::Fail;

/// The open console's actor name (the same value as the `forges` build's).
pub const OPEN_CONSOLE: &str = "\0open-console";

/// The refusal every forge door answers in this build.
pub const NOT_BUILT: &str = "forge import is not built into this console: it dials the public forges \
                             (github.com, gitlab.com, …), so it needs the `forges` feature (off by default) and GUNNAR_UI_FORGES=on";

/// No forge connection is ever held.
#[derive(Debug, Default)]
pub struct ForgeSessions;

impl ForgeSessions {
    pub fn new() -> ForgeSessions {
        ForgeSessions
    }
}

/// No OAuth application exists.
#[derive(Debug, Default)]
pub struct ForgeApps;

impl ForgeApps {
    pub fn from_env() -> ForgeApps {
        ForgeApps
    }

    pub fn allowing_private_bases() -> ForgeApps {
        ForgeApps
    }

    pub fn switched_on(self) -> ForgeApps {
        self
    }

    pub fn doors(&self) -> Vec<&'static str> {
        Vec::new()
    }
}

/// The refusal, as the console's error.
pub fn not_built() -> ApiError {
    ApiError(Fail { code: "failedprecondition".to_owned(), message: NOT_BUILT.to_owned() })
}

/// The handler every forge door is routed to in this build.
pub async fn door() -> ApiError {
    not_built()
}