Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow excluding repositories from being processed #1074

Merged
merged 1 commit into from
May 10, 2023
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
16 changes: 13 additions & 3 deletions clomonitor-registrar/src/registrar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ pub(crate) struct Repository {
pub name: String,
pub url: String,
pub check_sets: Vec<String>,
pub exclude: Option<Vec<String>>,
}

/// Process foundations registered in the database.
Expand Down Expand Up @@ -123,6 +124,14 @@ async fn process_foundation(
let tmp: Vec<Project> = serde_yaml::from_str(&data)?;
let mut projects_available: HashMap<String, Project> = HashMap::with_capacity(tmp.len());
for mut project in tmp {
// Do not include repositories that have been excluded for this service
project.repositories.retain(|r| {
if let Some(exclude) = &r.exclude {
return !exclude.contains(&"clomonitor".to_string());
}
true
});

project.set_digest()?;
projects_available.insert(project.name.clone(), project);
}
Expand Down Expand Up @@ -312,7 +321,7 @@ mod tests {
projects_registered.insert(
"artifact-hub".to_string(),
Some(
"bd6368c9e4b7e90ede6c16453ece0e9e4eef8464636aa3224db4be48d8e0c033"
"ee8c17885262dc623edaf6116e033a769046b068b8d8f81dadad6e43042a0340"
.to_string(),
),
);
Expand Down Expand Up @@ -362,11 +371,12 @@ mod tests {
devstats_url: Some("https://artifacthub.devstats.cncf.io/".to_string()),
accepted_at: Some("2020-06-23".to_string()),
maturity: "sandbox".to_string(),
digest: Some("bd6368c9e4b7e90ede6c16453ece0e9e4eef8464636aa3224db4be48d8e0c033".to_string()),
digest: Some("ee8c17885262dc623edaf6116e033a769046b068b8d8f81dadad6e43042a0340".to_string()),
repositories: vec![Repository{
name: "artifact-hub".to_string(),
url: "https://github.com/artifacthub/hub".to_string(),
check_sets: vec!["community".to_string(), "code".to_string()],
exclude: None,
}]
}),
)
Expand Down Expand Up @@ -406,7 +416,7 @@ mod tests {
projects_registered.insert(
"artifact-hub".to_string(),
Some(
"bd6368c9e4b7e90ede6c16453ece0e9e4eef8464636aa3224db4be48d8e0c033"
"ee8c17885262dc623edaf6116e033a769046b068b8d8f81dadad6e43042a0340"
.to_string(),
),
);
Expand Down
6 changes: 6 additions & 0 deletions clomonitor-registrar/src/testdata/cncf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,9 @@
check_sets:
- community
- code
- name: blog
url: https://github.com/artifacthub/blog
check_sets:
- docs
exclude:
- clomonitor