Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
ghostflow-director
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Utils
ghostflow-director
Merge requests
!5
io: support verifying all hook configuration blocks
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
io: support verifying all hook configuration blocks
ben.boeckel/ghostflow-director:hook-config-verification
into
master
Overview
3
Commits
1
Pipelines
1
Changes
2
Merged
Ben Boeckel
requested to merge
ben.boeckel/ghostflow-director:hook-config-verification
into
master
8 years ago
Overview
3
Commits
1
Pipelines
1
Changes
2
Expand
0
0
Merge request reports
Compare
master
master (base)
and
latest version
latest version
54f9d8dd
1 commit,
8 years ago
2 files
+
58
−
1
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
Search (e.g. *.vue) (Ctrl+P)
src/config/io.rs.in
+
56
−
0
Options
@@ -6,6 +6,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
extern crate itertools;
use self::itertools::Itertools;
extern crate serde;
use self::serde::{Deserialize, Deserializer};
use self::serde::Error as SerdeError;
@@ -14,6 +17,7 @@ extern crate serde_json;
use self::serde_json::Value;
use super::defaults;
use super::hooks;
use std::collections::hash_map::HashMap;
use std::error::Error;
@@ -202,4 +206,56 @@ impl Config {
pub fn archive_dir(&self) -> &Path {
Path::new(self.archive.as_ref().unwrap_or(&self.queue))
}
/// Verify all of the hook configuration blocks in the configuration file.
pub fn verify_all_hook_configs(self) -> Result<(), Box<Error>> {
// Check the hooks in each host.
self.hosts
.into_iter()
.map(|(_, host)| {
// And in each project.
host.projects
.into_iter()
.map(|(_, project)| {
// First get the project-wide hooks.
let project_hooks = project.hooks
.values()
.cloned()
.collect_vec();
project_hooks.into_iter()
// And merge them with the branch-specific hooks.
.chain(project.branches
.into_iter()
.map(|(_, branch)| {
branch.hooks
.into_iter()
.map(|(_, hook)| {
hook
})
})
.flatten())
})
.flatten()
})
.flatten()
// Split the hook configuration into an owned name and configuration block.
.map(|hook_config| {
(hook_config.name.clone(), hook_config.config)
})
// Parse each hook configuration section out.
.map(|(hook_name, config): (Option<String>, Value)| {
hook_name.map(|name| {
let mut hooks = Vec::new();
let mut branch_hook = Vec::new();
hooks::create_hook(&name, config, &mut hooks, &mut branch_hook)
})
})
// Skip any branch hooks which are deleting a project-level hook.
.filter_map(|x| x)
// Collect them up as results.
.collect::<Result<Vec<_>, _>>()
// And drop the actual hook results.
.map(|_| ())
}
}
Loading