Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions Cargo.lock

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

3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ git commit -s -m 'Commit message'

Once installed, this application will create a check indicating whether or not all commits in a Pull Request contain a valid `Signed-off-by` line.

> [!NOTE]
> Pull requests containing more than 1000 commits are not checked: the check fails with a message explaining why.

![check-passed](docs/screenshots/check-passed.png)

More information about the check result is available on the check details page. This information includes a full list of the commits checked (including the reason why each of them passed or failed the check), some additional details about each error found and some instructions on how to fix them.
Expand Down
4 changes: 2 additions & 2 deletions charts/dco2/templates/server_secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ stringData:
{{- if .Values.server.config.githubApp.apiHost }}
api_host: {{ .Values.server.config.githubApp.apiHost }}
{{- end }}
app_id: {{ .Values.server.config.githubApp.appId }}
app_id: {{ .Values.server.config.githubApp.appId | int64 }}
private_key: |-
{{ .Values.server.config.githubApp.privateKey | default "" | nindent 8 }}
webhook_secret: {{ .Values.server.config.githubApp.webhookSecret | quote }}
webhook_secret: {{ required "server.config.githubApp.webhookSecret is required" .Values.server.config.githubApp.webhookSecret | quote }}
log_format: {{ .Values.server.config.logFormat }}
server_addr: {{ .Values.server.config.addr }}
2 changes: 1 addition & 1 deletion charts/dco2/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ server:
appId: 0
# GitHub application private key
privateKey: ""
# GitHub webhook secret
# GitHub webhook secret (required, it cannot be empty)
webhookSecret: ""

# Log output format [json|pretty]
Expand Down
12 changes: 9 additions & 3 deletions dco2-aws-lambda/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ use figment::{Figment, providers::Env};
use lambda_http::{Error, run, tracing};

use dco2::github::{AppConfig, GHClientOctorust};
use dco2_server::handlers::setup_router;
use dco2_server::{env::env_with_raw_keys, handlers::setup_router};

/// Configuration keys whose environment variables values must not be parsed.
const RAW_ENV_KEYS: &[&str] = &["webhook_secret"];

#[tokio::main]
async fn main() -> Result<(), Error> {
Expand All @@ -18,11 +21,14 @@ async fn main() -> Result<(), Error> {
}
tracing::init_default_subscriber();

// Setup GitHub client
// Setup configuration
let cfg: AppConfig = Figment::new()
.merge(Env::prefixed("DCO2_"))
.merge(env_with_raw_keys(&Env::prefixed("DCO2_"), RAW_ENV_KEYS))
.extract()
.context("error setting up configuration")?;
cfg.validate().context("invalid configuration")?;

// Setup GitHub client
let gh_client = Arc::new(GHClientOctorust::new(&cfg).context("error setting up github client")?);

// Start lambda runtime
Expand Down
6 changes: 6 additions & 0 deletions dco2-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,9 @@ tower = { workspace = true }
tower-http = { workspace = true }
tracing = { workspace = true }
tracing-subscriber = { workspace = true }

[dev-dependencies]
async-trait = { workspace = true }
figment = { workspace = true, features = ["test"] }
indoc = { workspace = true }
tower = { workspace = true, features = ["util"] }
24 changes: 21 additions & 3 deletions dco2-server/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,21 @@

use std::path::PathBuf;

use anyhow::Result;
use anyhow::{Context, Result};
use figment::{
Figment,
providers::{Env, Format, Serialized, Yaml},
};
use serde::{Deserialize, Serialize};

use dco2::github::AppConfig;
use dco2_server::env::env_with_raw_keys;

#[cfg(test)]
mod tests;

/// Configuration keys whose environment variables values must not be parsed.
const RAW_ENV_KEYS: &[&str] = &["github_app.webhook_secret"];

/// Server configuration.
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
Expand All @@ -22,13 +29,24 @@ pub(crate) struct Config {
impl Config {
/// Create a new Config instance.
pub(crate) fn new(config_file: Option<&PathBuf>) -> Result<Self> {
// Setup defaults
let mut figment = Figment::new()
.merge(Serialized::default("log_format", "json"))
.merge(Serialized::default("server_addr", "localhost:9000"));

// Merge the config file provided (it must exist at the exact path)
if let Some(config_file) = config_file {
figment = figment.merge(Yaml::file(config_file));
figment = figment.merge(Yaml::file_exact(config_file));
}
figment.merge(Env::prefixed("DCO2_").split("__")).extract().map_err(Into::into)

// Merge the environment variables, which take precedence
let env = Env::prefixed("DCO2_").split("__");
let cfg: Self = figment.merge(env_with_raw_keys(&env, RAW_ENV_KEYS)).extract()?;

// Validate the resulting configuration
cfg.github_app.validate().context("invalid configuration")?;

Ok(cfg)
}
}

Expand Down
Loading
Loading