Work-in-progress reworking in Rust
This commit is contained in:
parent
1012975f35
commit
688e0cbe86
|
@ -1,2 +1,10 @@
|
|||
*.sw*
|
||||
node_modules/
|
||||
|
||||
|
||||
#Added by cargo
|
||||
#
|
||||
#already existing elements are commented out
|
||||
|
||||
/target
|
||||
**/*.rs.bk
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,20 @@
|
|||
[package]
|
||||
name = "contaminate"
|
||||
version = "0.1.0"
|
||||
authors = ["R. Tyler Croy <rtyler@brokenco.de>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
# Used for serving the website
|
||||
tide = "~0.5.1"
|
||||
async-std = "~1.4.0"
|
||||
|
||||
# Logging
|
||||
log = "~0.4.8"
|
||||
pretty_env_logger = "~0.3.1"
|
||||
|
||||
# Handling configuration overlays
|
||||
config = { version = "~0.10.1", features = ["yaml"] }
|
||||
|
||||
# Used for making http requests to the upstream docker registry
|
||||
surf = "~1.0.3"
|
46
README.adoc
46
README.adoc
|
@ -1,27 +1,51 @@
|
|||
= Contaminate
|
||||
|
||||
Hunting the white whale of a mutable immutable infrastructure.
|
||||
Contaminate is a caching proxy masquerading as Docker registry. It can modify
|
||||
Docker images and manifests on the fly, for those who need a little more mutability in their immutable infrastructure.
|
||||
|
||||
|
||||
== Environment Variables
|
||||
== Configuration
|
||||
|
||||
[%header, cols="^1,<.^4,^1,^1"]
|
||||
Contaminate can be configured with a `contaminate.yml` file, or via specific
|
||||
environment variables which can override configuration values.
|
||||
|
||||
=== YAML Keys
|
||||
|
||||
[cols="^1,<.^4,^1,^1"]
|
||||
|===
|
||||
.^| Name
|
||||
.^| Default Value
|
||||
.^| Notes
|
||||
|
||||
| `layers_dir`
|
||||
| `./layers.d`
|
||||
| A directory containing the layers to override on images passing through Contaminate.
|
||||
|
||||
| `registry`
|
||||
| https://registry-1.docker.io
|
||||
| A Registry HTTP V2 compliant URL, reachable by Contaminate.
|
||||
|
||||
|===
|
||||
|
||||
=== Environment Variables
|
||||
|
||||
[cols="^1,<.^4,^1,^1"]
|
||||
|===
|
||||
.^| Name
|
||||
.^| Default Value
|
||||
.^| Notes
|
||||
|
||||
|
||||
| `LAYERS_DIR`
|
||||
| `RUST_LOG`
|
||||
| `warn`
|
||||
| Log level for Contaminate logs to be printed
|
||||
|
||||
| `CT_LAYERS_DIR`
|
||||
| `./layers.d`
|
||||
| A directory containing the layers to override on images passing through Ahab
|
||||
| A directory containing the layers to override on images passing through Contaminate.
|
||||
|
||||
| `LOG_LEVEL`
|
||||
| `info`
|
||||
| Log level for Ahab logs to be printed
|
||||
|
||||
| `UPSTREAM_REGISTRY`
|
||||
| `CT_REGISTRY`
|
||||
| https://registry-1.docker.io
|
||||
| A Registry HTTP V2 compliant URL, reachable by Ahab.
|
||||
| A Registry HTTP V2 compliant URL, reachable by Contaminate.
|
||||
|
||||
|===
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
/**
|
||||
* The main server entrypoint for Contaminate
|
||||
*/
|
||||
|
||||
extern crate config;
|
||||
extern crate pretty_env_logger;
|
||||
|
||||
use async_std::task;
|
||||
use log::*;
|
||||
|
||||
/**
|
||||
* Load the settings based on the hierarchy.
|
||||
*
|
||||
* First we load the configuration file (contaminate.yml) if it exists
|
||||
* Then we look at environment variables.
|
||||
*/
|
||||
fn load_settings() -> config::Config {
|
||||
let mut settings = config::Config::default();
|
||||
settings.set_default("registry", "https://registry-1.docker.io")
|
||||
.expect("Could not set the default for `registry`");
|
||||
settings.set_default("layers_dir", "./layers.d")
|
||||
.expect("Could not set the default for `layers_dir`");
|
||||
|
||||
settings
|
||||
.merge(config::File::with_name("contaminate").required(false))
|
||||
.expect("Failed to load settings in contaminate.ymll")
|
||||
.merge(config::Environment::with_prefix("CT"))
|
||||
.expect("Failed to load settings defined by CT_* env vars");
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
fn main() -> Result<(), std::io::Error> {
|
||||
pretty_env_logger::init();
|
||||
|
||||
task::block_on(async {
|
||||
let mut app = tide::new();
|
||||
app.at("/").get(|_| async move { "Hello, world!" });
|
||||
app.listen("127.0.0.1:9000").await?;
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
}
|
Loading…
Reference in New Issue