Skip to content

Commit

Permalink
Merge pull request containers#2 from flouthoc/main
Browse files Browse the repository at this point in the history
cli: Integrate clap and bootstrap initial command structure.
  • Loading branch information
giuseppe authored Sep 22, 2021
2 parents 782c094 + d835a2f commit b2d9c4d
Show file tree
Hide file tree
Showing 10 changed files with 391 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bin
254 changes: 254 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[package]
name = "netavark"
version = "0.0.1"
edition = "2018"
authors = ["github.com/containers"]
description = "A container network stack"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
clap = "3.0.0-beta.4"
28 changes: 28 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# TODO: Make this more configurable
#prog :=xnixperms

debug ?=

$(info debug is $(debug))

ifdef debug
release :=
target :=debug
extension :=debug
else
release :=--release
target :=release
extension :=
endif

build:
cargo build $(release) --target-dir bin
cp bin/$(target)/netavark bin/netavark

clean:
rm -rf bin

all: build

help:
@echo "usage: make $(prog) [debug=1]"
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@ Netavark is capable of the following given the proper JSON input:
As this project is in very early development, we will add more capabilities in
the near future.

## Requires

- [Rust](https://www.rust-lang.org/tools/install)

## Build

```console
$ make
```
## Latest release
Not applicable yet (TBD)

## Latest release
Not applicable yet (TBD)

Expand All @@ -24,4 +36,4 @@ IRC `#podman` channel on `irc.libera.chat`.

For discussions around issues/bugs and features, you can use the GitHub
[issues](https://github.com/containers/netavark/issues)
and [PRs](https://github.com/containers/netavark/pulls) tracking system.
and [PRs](https://github.com/containers/netavark/pulls) tracking system.
2 changes: 2 additions & 0 deletions src/commands/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pub mod setup;
pub mod teardown;
23 changes: 23 additions & 0 deletions src/commands/setup.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//! Configures the given network namespace with provided specs
use std::path::PathBuf;
use clap::{self, Clap};

#[derive(Clap, Debug)]
pub struct Setup {
/// Network namespace path
#[clap(forbid_empty_values = true, required = true)]
network_namespace_path: String,
}

impl Setup {
/// The setup command configures the given network namespace with the given configuration, creating any interfaces and firewall rules necessary.
pub fn new(network_namespace_path: String) -> Self {
Self {
network_namespace_path,
}
}

pub fn exec(&self, input_file: PathBuf) {
()
}
}
22 changes: 22 additions & 0 deletions src/commands/teardown.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
use std::path::PathBuf;
use clap::{self, Clap};

#[derive(Clap, Debug)]
pub struct Teardown {
/// Network namespace path
#[clap(forbid_empty_values = true, required = true)]
network_namespace_path: String,
}

impl Teardown {
/// The teardown command is the inverse of the setup command, undoing any configuration applied. Some interfaces may not be deleted (bridge interfaces, for example, will not be removed).
pub fn new(network_namespace_path: String) -> Self {
Self {
network_namespace_path,
}
}

pub fn exec(&self, input_file: PathBuf) {
()
}
}
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod commands;
Loading

0 comments on commit b2d9c4d

Please sign in to comment.