From 2021054113c5175c15ca1e1bfc603504f77004ac Mon Sep 17 00:00:00 2001 From: Timon Borter Date: Fri, 20 Sep 2024 19:02:04 +0200 Subject: [PATCH] chore(license): apply licensing header to all source files --- README.md | 12 ++++---- src/argo_cd.rs | 5 +++ src/cli.rs | 5 +++ src/config.rs | 5 +++ src/database.rs | 5 +++ src/main.rs | 63 ++++++++++++++++++++++++++++++++++++++ src/password.rs | 5 +++ src/vault.rs | 5 +++ src/workflow.rs | 5 +++ tests/init_vault.rs | 5 +++ tests/rotate.rs | 5 +++ tests/utilities/src/lib.rs | 5 +++ 12 files changed, 119 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index b6edc30..1da2dfd 100644 --- a/README.md +++ b/README.md @@ -25,12 +25,6 @@
-
- Note: This project is still under construction. Features may be incomplete or subject to change. -
- -
- ## Target Architecture `propeller` is designed to seamlessly integrate with a specific application deployment architecture commonly used in modern environments: @@ -268,3 +262,9 @@ Please [create an issue](https://github.com/postfinance/propeller/issues/new), o **Welcome to the bottom of the README club! Since you've come this far, go ahead and smash that like and subsc… er, uh, give this project a ⭐️ on GitHub! 🙏🏼** Hats off to [@pmcelhaney](https://github.com/pmcelhaney/counterfact) for this amazing line that we couldn't resist stealing.. er, uh, which inspired us. Hope you don't mind 😏 + +## License + +This project is licensed under the MIT License. See the [`LICENSE` file](LICENSE) for details. + +Copyright (c) 2024 PostFinance AG diff --git a/src/argo_cd.rs b/src/argo_cd.rs index b806e93..1ae9a8f 100644 --- a/src/argo_cd.rs +++ b/src/argo_cd.rs @@ -1,3 +1,8 @@ +// Copyright (c) 2024 PostFinance AG +// +// This software is released under the MIT License. +// https://opensource.org/licenses/MIT + use log::{debug, info, warn}; use reqwest::header::CONTENT_TYPE; use reqwest::{Client, RequestBuilder}; diff --git a/src/cli.rs b/src/cli.rs index 547df3e..9b83042 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -1,3 +1,8 @@ +// Copyright (c) 2024 PostFinance AG +// +// This software is released under the MIT License. +// https://opensource.org/licenses/MIT + use clap::{Parser, Subcommand}; /// propeller - Automated database secret rotation. diff --git a/src/config.rs b/src/config.rs index 1f8cb33..f376a7b 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,3 +1,8 @@ +// Copyright (c) 2024 PostFinance AG +// +// This software is released under the MIT License. +// https://opensource.org/licenses/MIT + use log::debug; use serde::Deserialize; use std::{fs::File, io::Read, path::PathBuf}; diff --git a/src/database.rs b/src/database.rs index 7a7bfd7..2992e3d 100644 --- a/src/database.rs +++ b/src/database.rs @@ -1,3 +1,8 @@ +// Copyright (c) 2024 PostFinance AG +// +// This software is released under the MIT License. +// https://opensource.org/licenses/MIT + use postgres::{Client, NoTls}; use crate::config::{Config, PostgresConfig}; diff --git a/src/main.rs b/src/main.rs index f3fcb0a..01df379 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,8 @@ +// Copyright (c) 2024 PostFinance AG +// +// This software is released under the MIT License. +// https://opensource.org/licenses/MIT + use clap::Parser; use env_logger::{Env, DEFAULT_WRITE_STYLE_ENV}; @@ -42,3 +47,61 @@ fn init_logger() { env_logger::init_from_env(env); } + +#[cfg(test)] +mod tests { + use std::fs::{read_dir, read_to_string}; + use std::path::Path; + + #[test] + fn test_license_headers() { + let expected_header = r#"// Copyright (c) 2024 PostFinance AG +// +// This software is released under the MIT License. +// https://opensource.org/licenses/MIT + +"#; + + let directories = ["src", "tests"]; + + for dir in &directories { + verify_all_files_in_directory_start_with_license_header(dir, expected_header); + } + } + + fn verify_all_files_in_directory_start_with_license_header(dir: &str, expected_header: &str) { + let paths = read_dir(dir).unwrap(); + + for path in paths { + let path = path.unwrap().path(); + if should_process_path(&path) { + if path.is_dir() { + verify_all_files_in_directory_start_with_license_header( + path.to_str().unwrap(), + expected_header, + ); + } else if path.extension().and_then(|s| s.to_str()) == Some("rs") { + verify_file_starts_with_license_header(&path, expected_header); + } + } + } + } + + fn should_process_path(path: &Path) -> bool { + let path_str = path.to_str().unwrap(); + if path_str.starts_with("tests/utilities") { + path_str == "tests/utilities/src" || path_str.starts_with("tests/utilities/src/") + } else { + true + } + } + + fn verify_file_starts_with_license_header(path: &Path, expected_header: &str) { + let contents = read_to_string(path).unwrap(); + assert!( + contents.starts_with(expected_header), + "File {} does not start with the expected license header", + path.display() + ); + } +} diff --git a/src/password.rs b/src/password.rs index 9621412..03cc509 100644 --- a/src/password.rs +++ b/src/password.rs @@ -1,3 +1,8 @@ +// Copyright (c) 2024 PostFinance AG +// +// This software is released under the MIT License. +// https://opensource.org/licenses/MIT + use log::trace; use rand::distr::Alphanumeric; use rand::{thread_rng, Rng}; diff --git a/src/vault.rs b/src/vault.rs index 0038da0..a303d9f 100644 --- a/src/vault.rs +++ b/src/vault.rs @@ -1,3 +1,8 @@ +// Copyright (c) 2024 PostFinance AG +// +// This software is released under the MIT License. +// https://opensource.org/licenses/MIT + use std::env; use log::{debug, info}; diff --git a/src/workflow.rs b/src/workflow.rs index 0693c60..58f2806 100644 --- a/src/workflow.rs +++ b/src/workflow.rs @@ -1,3 +1,8 @@ +// Copyright (c) 2024 PostFinance AG +// +// This software is released under the MIT License. +// https://opensource.org/licenses/MIT + use log::{debug, error, info, trace}; use crate::argo_cd::ArgoCD; diff --git a/tests/init_vault.rs b/tests/init_vault.rs index eb6d527..3b230e1 100644 --- a/tests/init_vault.rs +++ b/tests/init_vault.rs @@ -1,3 +1,8 @@ +// Copyright (c) 2024 PostFinance AG +// +// This software is released under the MIT License. +// https://opensource.org/licenses/MIT + use std::process::{Command, Stdio}; use assert_cmd::prelude::*; diff --git a/tests/rotate.rs b/tests/rotate.rs index 5818f98..a78a54b 100644 --- a/tests/rotate.rs +++ b/tests/rotate.rs @@ -1,3 +1,8 @@ +// Copyright (c) 2024 PostFinance AG +// +// This software is released under the MIT License. +// https://opensource.org/licenses/MIT + use assert_cmd::prelude::*; use ntest::timeout; use postgres::NoTls; diff --git a/tests/utilities/src/lib.rs b/tests/utilities/src/lib.rs index 35b7cd6..40cb3a8 100644 --- a/tests/utilities/src/lib.rs +++ b/tests/utilities/src/lib.rs @@ -1,3 +1,8 @@ +// Copyright (c) 2024 PostFinance AG +// +// This software is released under the MIT License. +// https://opensource.org/licenses/MIT + use base64::engine::general_purpose::STANDARD as BASE64_STANDARD; use base64::Engine; use futures::StreamExt;