Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Sundog to handle dynamic settings #49

Merged
merged 14 commits into from Jul 9, 2019
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions packages/api/api.spec
Expand Up @@ -9,6 +9,7 @@ License: Apache-2.0 AND (Apache-2.0 OR BSL-1.0) AND (Apache-2.0 OR MIT) AND Apac
Source0: %{workspace_name}.crate
Source1: apiserver.service
Source2: moondog.service
Source3: sundog.service
%cargo_bundle_crates -n %{workspace_name} -t 0
BuildRequires: gcc-%{_cross_target}
BuildRequires: %{_cross_os}glibc-devel
Expand All @@ -29,6 +30,12 @@ Requires: %{_cross_os}apiserver = %{version}-%{release}
%description -n %{_cross_os}moondog
%{summary}.

%package -n %{_cross_os}sundog
Summary: Updates settings dynamically based on user-specified generators
Requires: %{_cross_os}apiserver = %{version}-%{release}
%description -n %{_cross_os}sundog
%{summary}.

%package -n %{_cross_os}thar-be-settings
Summary: Applies changed settings to a Thar system
Requires: %{_cross_os}apiserver = %{version}-%{release}
Expand All @@ -49,9 +56,11 @@ Requires: %{_cross_os}apiserver = %{version}-%{release}
mkdir -p %{buildroot}/%{systemd_systemdir}
install -m 0644 -t %{buildroot}/%{systemd_systemdir} %{SOURCE1}
install -m 0644 -t %{buildroot}/%{systemd_systemdir} %{SOURCE2}
install -m 0644 -t %{buildroot}/%{systemd_systemdir} %{SOURCE3}

%cargo_install -p apiserver
%cargo_install -p moondog
%cargo_install -p sundog
%cargo_install -p thar-be-settings

%files -n %{_cross_os}apiserver
Expand All @@ -62,6 +71,10 @@ install -m 0644 -t %{buildroot}/%{systemd_systemdir} %{SOURCE2}
%{_cross_bindir}/moondog
%{systemd_systemdir}/moondog.service

%files -n %{_cross_os}sundog
%{_cross_bindir}/sundog
%{systemd_systemdir}/sundog.service

%files -n %{_cross_os}thar-be-settings
%{_cross_bindir}/thar-be-settings

Expand Down
14 changes: 14 additions & 0 deletions packages/api/sundog.service
@@ -0,0 +1,14 @@
[Unit]
Description=Updates settings dynamically based on user-specified generators
After=network-online.target
After=apiserver.service
After=moondog.service
Requires=network-online.target
Requires=apiserver.service

[Service]
Type=oneshot
ExecStart=/usr/bin/sundog

[Install]
WantedBy=multi-user.target
1 change: 1 addition & 0 deletions packages/release/release.spec
Expand Up @@ -29,6 +29,7 @@ Requires: %{_cross_os}kernel
Requires: %{_cross_os}moondog
Requires: %{_cross_os}ripgrep
Requires: %{_cross_os}signpost
Requires: %{_cross_os}sundog
Requires: %{_cross_os}systemd
Requires: %{_cross_os}thar-be-settings
Requires: %{_cross_os}util-linux
Expand Down
14 changes: 14 additions & 0 deletions workspaces/api/Cargo.lock

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

1 change: 1 addition & 0 deletions workspaces/api/Cargo.toml
Expand Up @@ -2,6 +2,7 @@
members = [
"apiserver",
"moondog",
"sundog",
"thar-be-settings",
]

Expand Down
19 changes: 19 additions & 0 deletions workspaces/api/sundog/Cargo.toml
@@ -0,0 +1,19 @@
[package]
name = "sundog"
version = "0.1.0"
authors = ["mrowicki <mrowicki@amazon.com>"]
edition = "2018"
publish = false
build = "build.rs"

[dependencies]
apiserver = { path = "../apiserver" }
reqwest = { version = "0.9", default-features = false, features = [] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1"
snafu = "0.4"
log = "0.4"
stderrlog = "0.4"

[build-dependencies]
cargo-readme = "3.1"
14 changes: 14 additions & 0 deletions workspaces/api/sundog/README.md
@@ -0,0 +1,14 @@
# sundog

Current version: 0.1.0

## Introduction

sundog is a small program to handle settings that must be generated at OS runtime.

It requests settings generators from the API and runs them.
The output is collected and sent to a known Thar API server endpoint and committed.

## Colophon

This text was generated using [cargo-readme](https://crates.io/crates/cargo-readme), and includes the rustdoc from `src/main.rs`.
9 changes: 9 additions & 0 deletions workspaces/api/sundog/README.tpl
@@ -0,0 +1,9 @@
# {{crate}}

Current version: {{version}}

{{readme}}

## Colophon

This text was generated using [cargo-readme](https://crates.io/crates/cargo-readme), and includes the rustdoc from `src/main.rs`.
25 changes: 25 additions & 0 deletions workspaces/api/sundog/build.rs
@@ -0,0 +1,25 @@
// Automatically generate README.md from rustdoc.

use std::fs::File;
use std::io::Write;
use std::path::PathBuf;

fn main() {
let mut source = File::open("src/main.rs").unwrap();
let mut template = File::open("README.tpl").unwrap();

let content = cargo_readme::generate_readme(
&PathBuf::from("."), // root
&mut source, // source
Some(&mut template), // template
// The "add x" arguments don't apply when using a template.
true, // add title
false, // add badges
false, // add license
true, // indent headings
)
.unwrap();

let mut readme = File::create("README.md").unwrap();
readme.write_all(content.as_bytes()).unwrap();
}