-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: initialize dfinit crate (#330)
Signed-off-by: Gaius <[email protected]>
- Loading branch information
Showing
12 changed files
with
172 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright 2024 The Dragonfly Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
use std::path::PathBuf; | ||
|
||
// NAME is the name of dfinit. | ||
pub const NAME: &str = "dfinit"; | ||
|
||
// default_dfinit_config_path is the default config path for dfinit. | ||
#[inline] | ||
pub fn default_dfinit_config_path() -> PathBuf { | ||
super::default_config_dir().join("dfinit.yaml") | ||
} | ||
|
||
// default_dfinit_log_dir is the default log directory for dfinit. | ||
pub fn default_dfinit_log_dir() -> PathBuf { | ||
super::default_log_dir().join(NAME) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[package] | ||
name = "dragonfly-client-init" | ||
description = "Initialize runtime environment of the dfdaemon" | ||
version.workspace = true | ||
authors.workspace = true | ||
homepage.workspace = true | ||
repository.workspace = true | ||
keywords.workspace = true | ||
license.workspace = true | ||
readme.workspace = true | ||
edition.workspace = true | ||
|
||
[[bin]] | ||
name = "dfinit" | ||
path = "src/bin/main.rs" | ||
|
||
[dependencies] | ||
dragonfly-client-config.workspace = true | ||
clap.workspace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
FROM rust:1.75.0 as builder | ||
|
||
RUN apt-get update && apt-get install -y openssl libclang-dev pkg-config protobuf-compiler | ||
|
||
WORKDIR /app/client | ||
COPY Cargo.toml ./ | ||
COPY Cargo.lock ./ | ||
|
||
COPY dragonfly-client-init/Cargo.toml ./dragonfly-client-init/Cargo.toml | ||
COPY dragonfly-client-init/src ./dragonfly-client-init/src | ||
|
||
RUN cargo build --release --verbose | ||
|
||
FROM debian:bookworm-slim | ||
|
||
RUN apt-get update && apt-get install -y --no-install-recommends wget \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
COPY --from=builder /app/client/target/release/dfinit /usr/local/bin/dfinit | ||
|
||
ENTRYPOINT ["/usr/local/bin/dfinit"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright 2024 The Dragonfly Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
use clap::Parser; | ||
use dragonfly_client_config::dfinit; | ||
use std::path::PathBuf; | ||
|
||
#[derive(Debug, Parser)] | ||
#[command( | ||
name = dfinit::NAME, | ||
author, | ||
version, | ||
about = "dfinit is a command line for initializing runtime environment of the dfdaemon", | ||
long_about = "A command line for initializing runtime environment of the dfdaemon, \ | ||
For example, if the container's runtime is containerd, then dfinit will modify the mirror configuration of containerd and restart the containerd service. \ | ||
It also supports to change configuration of the other container's runtime, such as cri-o, docker, etc." | ||
)] | ||
struct Args { | ||
#[arg( | ||
short = 'c', | ||
long = "config", | ||
default_value_os_t = dfinit::default_dfinit_config_path(), | ||
help = "Specify config file to use") | ||
] | ||
config: PathBuf, | ||
} | ||
|
||
fn main() { | ||
// Parse command line arguments. | ||
let args = Args::parse(); | ||
|
||
println!("{:?}", args); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.