test with docker-api (no oficial) lib

This commit is contained in:
2023-06-12 19:43:14 +02:00
commit 2b0d2b07d1
11 changed files with 2108 additions and 0 deletions

52
src/conf/mod.rs Normal file
View File

@@ -0,0 +1,52 @@
use std::net::{Ipv4Addr, SocketAddrV4};
use rusqlite::{Connection, Result};
const PATH: &str = "mdeploy.db";
pub struct ConfServer{
ip: String,
port: String,
ip_top_limit: u8,
ip_base_limit: u8,
}
pub struct MInstance {
id: i64,
ip: Ipv4Addr,
}
pub struct instance {
con: Connection,
}
impl instance {
pub fn new() -> Result<Self> {
let con = Connection::open(PATH)?;
let ret = Self {
con : con,
};
ret.create_table()?;
Ok(ret)
}
fn create_table(&self) -> Result<()> {
self.con.execute_batch(
"BEGIN;
CREATE TABLE IF NOT EXISTS images(
id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT UNIQUE);
CREATE TABLE IF NOT EXISTS l_instances(
id INTEGER PRIMARY KEY AUTOINCREMENT,
ip TEXT,
image INTEGER
FOREIGN KEY(INTEGER) REFERENCES images(id));
COMMIT;"
)
}
fn insert_image(&self, image: String){
}
}