Skip to content

Commit

Permalink
Add separate example config for Windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
de-vri-es committed Sep 30, 2023
1 parent fbb8f49 commit fb0fd37
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 2 deletions.
64 changes: 64 additions & 0 deletions example-config.windows.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# By default, the server accepts connections on all addresses.
# You can limit this by setting `bind-address` to a specific IP address.
bind-address: "::"

# Choose a port number to listen on.
port: 8091

# The log level of the server.
# You can choose from: error, warn, info, debug and trace.
log-level: info

# The TLS section is optional.
# If it is present, the server will only accept HTTPS requests.
# tls:
# private-key: /etc/letsencrypt/live/example.com/privkey.pem
# certificate-chain: /etc/letsencrypt/live/example.com/fullchain.pem

# The hooks.
hooks:
# A hook that prints the script environment, useful for debugging.
# Output is sent to the server log, not as HTTP response body.
- url: "/print-env"
commands:
- cmd: ["cmd.exe","/c","set"]

# A hook that prints the current working directory, useful for debugging.
# Output is sent to the server log, not as HTTP response body.
- url: "/print-cwd-win32"
commands:
- cmd: ["cmd.exe","/c","cd"]

# A hook that handles file uploads from a multipart/form-data request.
# You need to run `cargo build --examples` for this hook to work.
- url: "/multipart-stdin"
commands:
- cmd: ["target/debug/examples/multipart-stdin"]
stdin: request-body
environment:
OUTPUT_FOLDER: uploads
COUNT_SUFFIX: 1
APPLY_TIMESTAMP: 1

- url: "/make-release-tarball"
commands:
- cmd: ["make-release-tarball"]
stdin: request-body
working-dir: "/path/to/repository/"
# Run only one concurrent job, but queue all requests in a FIFO queue.
max-concurrent: 1
queue-size: unlimited
queue-type: fifo
# The secret used to verify the `X-Hub-Signature-256` header.
# Always generate your own random secrets.
secret: "some-randomly-generated-secret"

- url: "/update-daemon-config"
# This hook uses the default scheduling parameters.
# That means at most a single concurrent job,
# and a LIFO queue with a maximum queue size of 1.
commands:
- cmd: ["git", "fetch"]
- cmd: ["git", "reset", "--hard", "origin/main"]
- cmd: ["systemctl", "reload", "my-little-service"]
working-dir: "/etc/my-little-service/"
15 changes: 13 additions & 2 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ use indexmap::IndexMap;
use crate::logging::LogLevel;
use crate::types::QueueType;

#[cfg(any(test, not(windows)))]
const EXAMPLE_CONFIG_UNIX: &str = include_str!("../example-config.yaml");
#[cfg(any(test, windows))]
const EXAMPLE_CONFIG_WINDOWS: &str = include_str!("../example-config.windows.yaml");

#[derive(Debug, Clone, Deserialize)]
#[serde(deny_unknown_fields)]
#[serde(rename_all = "kebab-case")]
Expand Down Expand Up @@ -129,7 +134,12 @@ impl Config {
}

pub fn example() -> &'static str {
include_str!("../example-config.yaml")
#[cfg(not(windows))] {
EXAMPLE_CONFIG_UNIX
}
#[cfg(windows)] {
EXAMPLE_CONFIG_WINDOWS
}
}
}

Expand Down Expand Up @@ -245,6 +255,7 @@ mod test {

#[test]
fn deserialize_example_hooks() {
assert!(let Ok(_) = Config::parse(Config::example()))
assert!(let Ok(_) = Config::parse(EXAMPLE_CONFIG_UNIX));
assert!(let Ok(_) = Config::parse(EXAMPLE_CONFIG_WINDOWS));
}
}

0 comments on commit fb0fd37

Please sign in to comment.