Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fn main() {
context.config_mut().build.dist_dir = AppUrl::Url(window_url.clone());

builder = builder
.invoke_handler(tauri::generate_handler![connect_beiboot_ghostunnel, disconnect_beiboot_ghostunnel, write_kubeconfig, cleanup, start_server, check_running_connects, establish_heartbeat_connection])
.invoke_handler(tauri::generate_handler![connect_beiboot_ghostunnel, disconnect_beiboot_ghostunnel, write_kubeconfig, cleanup, start_server, check_running_connects, establish_heartbeat_connection, check_docker_engine])
.plugin(tauri_plugin_localhost::Builder::new(port).build())
.plugin(tauri_plugin_store::Builder::default().build())
.setup(move |app| {
Expand Down Expand Up @@ -149,3 +149,14 @@ async fn establish_heartbeat_connection(cluster_id: &str, token: &str) -> Result
}
}
}

#[tauri::command]
async fn check_docker_engine() -> Result<String, String> {
match util::check_docker_engine().await {
Ok(res) => Ok(res),
Err(why) => {
println!("{}", why);
Err(format!("{}", why))
}
}
}
9 changes: 9 additions & 0 deletions src-tauri/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::fs::{File,create_dir_all};
use std::io::prelude::*;
use std::env::temp_dir;
use std::path::PathBuf;
use bollard::Docker;

pub fn write_conf_file(beiboot_name: String, content: &str, file_type: &str) -> Result<String, String> {

Expand Down Expand Up @@ -47,6 +48,14 @@ pub fn cleanup(beiboot_name: String) -> Result<(), String> {
}
}

pub async fn check_docker_engine() -> Result<String, String> {
let docker = Docker::connect_with_local_defaults().unwrap();
match docker.info().await {
Ok(_) => Ok("Docker engine is running".to_string()),
Err(why) => Err(format!("{}", why))
}
}

#[cfg(test)]
mod tests {
#[test]
Expand Down
4 changes: 4 additions & 0 deletions src/beibootctl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,7 @@ export async function checkRunningConnects() {
}
return res
}
export async function checkDockerEngine() {
let res: string = await invoke("check_docker_engine", {})
return res
}
2 changes: 1 addition & 1 deletion src/components/ClusterTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<td>
<v-tooltip text="Connect">
<template v-slot:activator="{ props }">
<v-btn v-bind="props" class="mt-2 mb-1 mr-2" size="small" variant="flat" color="secondary" icon="mdi-lan-connect" @click="clusterConnect(cluster.id, cluster.name)" v-if="store.connection.clusterName !== cluster.name" :disabled="!!store.connection.clusterName || cluster.state !== 'READY'"></v-btn>
<v-btn v-bind="props" class="mt-2 mb-1 mr-2" size="small" variant="flat" color="secondary" icon="mdi-lan-connect" @click="clusterConnect(cluster.id, cluster.name)" v-if="store.connection.clusterName !== cluster.name" :disabled="!!store.connection.clusterName || cluster.state !== 'READY' || !store.docker"></v-btn>
</template>
</v-tooltip>
<v-tooltip text="Disconnect">
Expand Down
2 changes: 1 addition & 1 deletion src/layouts/default/Default.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
</v-menu>
<v-btn v-else>Not logged in</v-btn>
<v-spacer></v-spacer>
<v-btn>Engine: Docker</v-btn>
<v-btn>{{ appStore.docker ? "Engine: Docker" : "Docker Engine not running" }}</v-btn>
<v-menu v-if="true">
<template v-slot:activator="{ props }">
<v-btn v-if="appStore.connection.connected" v-bind="props">Connected to {{ appStore.connection.clusterName }}</v-btn>
Expand Down
11 changes: 11 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { initKeycloak } from '@/auth/keycloak';
import * as Sentry from "@sentry/vue";
import { invoke } from '@tauri-apps/api/tauri';
import { useAppStore } from './store/app';
import { checkDockerEngine } from './beibootctl';

const app = createApp(App)

Expand Down Expand Up @@ -52,4 +53,14 @@ if (process.env.NODE_ENV !== 'debug') {
document.addEventListener('contextmenu', event => event.preventDefault());
}

const appStore = useAppStore();

checkDockerEngine().then((res) => {
console.log("docker engine: ", res);
appStore.docker = true;
}).catch((err) => {
console.log("docker engine: ", err);
appStore.docker = false;
})

initKeycloak();
1 change: 1 addition & 0 deletions src/store/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const useAppStore = defineStore('appStore', {
kubeconfigPath: "",
connected: false,
},
docker: false,
auth: {
authenticated: false,
user: "",
Expand Down