mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 20:14:49 +00:00
compat
This commit is contained in:
committed by
Aiden McClelland
parent
c6391280fc
commit
2e3e551564
4
compat/.gitignore
vendored
Normal file
4
compat/.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
/target
|
||||
**/*.rs.bk
|
||||
.DS_Store
|
||||
.vscode
|
||||
3079
compat/Cargo.lock
generated
Normal file
3079
compat/Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
13
compat/Cargo.toml
Normal file
13
compat/Cargo.toml
Normal file
@@ -0,0 +1,13 @@
|
||||
[package]
|
||||
name = "compat"
|
||||
version = "0.1.0"
|
||||
authors = ["Aiden McClelland <me@drbonez.dev>"]
|
||||
edition = "2018"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
clap = "2.33.3"
|
||||
serde = { version="1.0.118", features=["derive", "rc"] }
|
||||
serde_yaml = "0.8.17"
|
||||
embassy-os = { path="../appmgr", default-features=false }
|
||||
5
compat/Dockerfile
Normal file
5
compat/Dockerfile
Normal file
@@ -0,0 +1,5 @@
|
||||
FROM alpine:latest
|
||||
|
||||
ADD ./target/aarch64-unknown-linux-musl/release/compat /usr/local/bin/compat
|
||||
|
||||
ENTRYPOINT ["compat"]
|
||||
45
compat/src/main.rs
Normal file
45
compat/src/main.rs
Normal file
@@ -0,0 +1,45 @@
|
||||
use std::{fs::File, io::stdout, path::Path};
|
||||
|
||||
use clap::{App, Arg, SubCommand};
|
||||
use embassy::config::action::{ConfigRes, SetResult};
|
||||
|
||||
fn main() {
|
||||
let app = App::new("compat").subcommand(
|
||||
SubCommand::with_name("config").subcommand(
|
||||
SubCommand::with_name("get")
|
||||
.arg(
|
||||
Arg::with_name("mountpoint")
|
||||
.help("The `mount` field from manifest.yaml")
|
||||
.required(true),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("spec")
|
||||
.help("The path to the config spec in the container")
|
||||
.required(true),
|
||||
),
|
||||
),
|
||||
);
|
||||
let matches = app.get_matches();
|
||||
match matches.subcommand() {
|
||||
("config", Some(sub_m)) => match sub_m.subcommand() {
|
||||
("get", Some(sub_m)) => {
|
||||
let cfg_path =
|
||||
Path::new(sub_m.value_of("mountpoint").unwrap()).join("start9/config.yaml");
|
||||
let cfg = if cfg_path.exists() {
|
||||
Some(serde_yaml::from_reader(File::open(cfg_path).unwrap()).unwrap())
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let spec_path = Path::new(sub_m.value_of("spec").unwrap());
|
||||
let spec = serde_yaml::from_reader(File::open(spec_path).unwrap()).unwrap();
|
||||
serde_yaml::to_writer(stdout(), &ConfigRes { config: cfg, spec }).unwrap();
|
||||
}
|
||||
(subcmd, _) => {
|
||||
panic!("unknown subcommand: {}", subcmd);
|
||||
}
|
||||
},
|
||||
(subcmd, _) => {
|
||||
panic!("unknown subcommand: {}", subcmd);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user