-
Notifications
You must be signed in to change notification settings - Fork 524
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add "schnauzer" generator for parameterized setting values
This lets settings be generated based on a template that reference other settings. The first example is regional container image URIs, where we replace part with the value of settings.aws.region. The template is stored as a new metadata key, next to the setting-generator metadata, which schnauzer will read from the API. For example, if the template is "foo-{{ settings.bar }}" and "settings.bar" is set to "baz", then the setting output will be "foo-baz". To be able to reference other settings from sundog-spawned generators, we need to commit settings that have already been patched, e.g. from user data. To do this, this commit eliminates the settings-committer service, instead using the settings-committer binary as an ExecStartPre on any service that requires committed settings.
- Loading branch information
Showing
29 changed files
with
511 additions
and
204 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
This file was deleted.
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
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 |
---|---|---|
@@ -1 +1 @@ | ||
<mxfile modified="2019-09-03T17:53:54.335Z" host="drawio.corp.amazon.com" agent="Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0" etag="1CiXTfHJy2oos7HLSLhY" version="10.9.7" type="device"><diagram id="vL4lszIxdcRJnpUGa12-" name="Page-1">3Vpbc+I2FP41zLQPZHzBhDwuue10m9lsmE7TvnSELYwmsuXKIkB+/UpYAlsS2AFDyOYhYx/JMvrOd65yx79OFvcUZNMHEkHc8Zxo0fFvOp531fP4fyFYFgLXcQeFJKYokrKNYITeoJoopTMUwbwykRGCGcqqwpCkKQxZRQYoJfPqtAnB1bdmIIaGYBQCbEr/RhGbSqnrOJuBrxDFU/nqQSAHEqAmS0E+BRGZl0T+bce/poSw4ipZXEMswFO4FM/dbRld/zAKU9bkgeET/Cv8/49v/Xs6Xdw8wRdvlHblKq8Az+SGO14f8/WGEXrll7G4TFBMASNUDfF3lEbl7thSQUbJLI2geKvLh+dTxOAoA6EYnXOScNmUJVgOm7tQPwlSBhclkdzVPSQJZHTJpyhO9YLikflGQQMJ+rSkGl9OA5IS8XqlDWr8QgL3DhB9A8ScowXnBE8+DhxlgRKIc8GqZ2AVAQZWGHHIDLi40WTiMlxixHGj9ZiNC4D/HK8FIHyJV7B/nzG+CmwP3CCogGtC27dAq+BuHdqgkS0TkkYk3mbKxvzfJojmjC87Fo7Kc0iKl7+reWOqP3kurkGO+k49/deu/CT87xtKAhnKIeV7MtDiy/EwB+uRmpCUydDJw2sryLmDKnIW3LxTkntg+thZQeQPpljPPTMPq35PGSrIGErjvBuSJEGMWbh2atgCv4Fl+ifFzcyF1riBLMPoDFDrXzZAzT0pap6BGk/FJyieURhdMEBjyLZG9SlcgJikHJsMUsR/kAjwSvqoRN5JoB14GrR+Q5cXHMvluWZeaYaINPoiqhyRImGQ5yjkaOQcdmaKS3itZtwhXItfTmY0hPUFhFR0bd4Ho0q5ZWqjhHawA2wKMWDotVqk2TQg3/BIUMpK0U3TtaOZR7Ft+VC5ptLW6WtBUlumQMVYZsWG9Z4PIIgt43s3QVIiUuJt7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z" host="drawio.corp.amazon.com" agent="Mozilla/5.0 (X11; Linux x86_64; rv:72.0) Gecko/20100101 Firefox/72.0" etag="O4bPJ8mCazPHc_QchX88" version="12.4.8" type="device"><diagram id="vL4lszIxdcRJnpUGa12-" name="Page-1">3Vtbc5s4FP41ntl9cIaLIc5jru1st5O0np1N96WjgIw1kRERcmz3168EAgMStmyD67YPGTgSwnznO1epA/d2vvpAQTL7TEKIB44Vrgbu3cBxrkYO/ysE61xgW7aURBSFUrYRTNAPWEyU0gUKYVqbyAjBDCV1YUDiGAasJgOUkmV92pTg+lsTEEFFMAkAVqX/opDNpNS2rM3AR4iimXz12JMDc1BMloJ0BkKyrIjc+4F7Swlh+dV8dQuxAK/AJX/uoWW0/GEUxszkgZuv8J/g7a9P/gc6W919ha/OJB7KVd4BXsgPHjg+5uvdhOidX0bico4iChihxRB/R2VUfh1bF5BRsohDKN5q8+HlDDE4SUAgRpecJFw2Y3Msh9WvKH4SpAyuKiL5VR8gmUNG13xKwamRlz+y3ChoLEGfVVTjymlAUiIqV9qgxi8kcHuA6CogphwtuCR4+vPAKSxQAnEuWI0UrELAQIYRh0yBixtNIi6DNUYcN7obs5cc4L9fSgEIXqMM9scF46vA7sD1vBq4KrS+BtoC7s6h9YxsmZA4JFGbKSvz/5gimjK+7ItwVI5FYrz+s5j3QptPnotrkKOutZv+pSs/Cf99RUkgQSmk/JsUtPhyPMzB3UhNScxk6LTH3SBnj+vIaXBzTknuIm2oAMdD/hRFCwrDCwZoBFmr95jBFYhIzJFJIEX8BwlHUkifCpFzEkpe+nWnYY8sM2i93qBV45dKxTi8FtmUcMUYpCkKOBoph52p4gpe2YwHhHfil5IFDeDuREUqemd8gWEtrVO1UUHb2wI2hRgw9F5PBnUakG94IihmFStquB+r4Vbyz5YPVXO3xjp+wxgby+SoKMtkbCi/+QiC6CLL3gSJiQi9beywjmKH+0uyY1jaudTr6FB+DC/rC7n9MeTz6NmZgB9fHm4fh/Q/AD47H7G2jDAhiIlr3al8z1D5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X7xfqtNLLuw3zwma5sJdNNK37kFVOZYnNekQJAlGmubXEWwzJJd5bOifXPx2c3g+t+zNf0Fw7/8H</diagram></mxfile> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,21 @@ | ||
[package] | ||
name = "schnauzer" | ||
version = "0.1.0" | ||
authors = ["Tom Kirchner <tjk@amazon.com>"] | ||
edition = "2018" | ||
publish = false | ||
build = "build.rs" | ||
|
||
[dependencies] | ||
apiclient = { path = "../apiclient" } | ||
base64 = "0.11" | ||
handlebars = "3.0" | ||
http = "0.1" | ||
log = "0.4" | ||
models = { path = "../../models" } | ||
serde = { version = "1.0", features = ["derive"] } | ||
serde_json = "1" | ||
snafu = "0.6" | ||
|
||
[build-dependencies] | ||
cargo-readme = "3.1" |
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,20 @@ | ||
# schnauzer | ||
|
||
Current version: 0.1.0 | ||
|
||
## Introduction | ||
|
||
schnauzer is called by sundog as a setting generator. | ||
Its sole parameter is the name of the setting to generate. | ||
|
||
The setting we're generating is expected to have a metadata key already set: "template". | ||
"template" is an arbitrary string with mustache template variables that reference other settings. | ||
|
||
For example, if we're generating "settings.x" and we have template "foo-{{ settings.bar }}", we look up the value of "settings.bar" in the API. | ||
If the returned value is "baz", our generated value will be "foo-baz". | ||
|
||
(The name "schnauzer" comes from the fact that Schnauzers are search and rescue dogs (similar to this search and replace task) and because they have mustaches.) | ||
|
||
## Colophon | ||
|
||
This text was generated from `README.tpl` using [cargo-readme](https://crates.io/crates/cargo-readme), and includes the rustdoc from `src/main.rs`. |
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,9 @@ | ||
# {{crate}} | ||
|
||
Current version: {{version}} | ||
|
||
{{readme}} | ||
|
||
## Colophon | ||
|
||
This text was generated from `README.tpl` using [cargo-readme](https://crates.io/crates/cargo-readme), and includes the rustdoc from `src/main.rs`. |
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,32 @@ | ||
// Automatically generate README.md from rustdoc. | ||
|
||
use std::env; | ||
use std::fs::File; | ||
use std::io::Write; | ||
use std::path::PathBuf; | ||
|
||
fn main() { | ||
// Check for environment variable "SKIP_README". If it is set, | ||
// skip README generation | ||
if env::var_os("SKIP_README").is_some() { | ||
return; | ||
} | ||
|
||
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(); | ||
} |
Oops, something went wrong.