Skip to content

Commit

Permalink
Set max_tags to 1500 to ensure all tags return.
Browse files Browse the repository at this point in the history
Handle multiple newer versions to ensure only  latest version is returned.
Ensure include and exclude filters can be applied.
  • Loading branch information
slackspace-io committed Apr 14, 2024
1 parent 9b0b117 commit 705b457
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/repocheck/repocheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ pub async fn get_tags_for_image(image: &str) -> Result<Vec<String>, Box<dyn std:
let auth = RegistryAuth::Anonymous;
let config = ClientConfig::default();
let mut client = Client::new(config);
let max_tags = Some(1500);
log::info!("Fetching tags for image: {:?}", reference.tag());
let tags = client
.list_tags(&reference, &auth, None, reference.tag())
.list_tags(&reference, &auth, max_tags, reference.tag())
.await?;
log::info!("Available tags for {}: {:?}", reference, tags.tags);
//length of tags
Expand Down
13 changes: 10 additions & 3 deletions src/services/workloads.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ pub async fn parse_tags(workload: &Workload) -> Result<Workload, Box<dyn std::er
.collect();

log::info!("Filtered tags: {:?}", tags);
} else if let Some(exclude_pattern_str) = &workload.exclude_pattern {
}
if let Some(exclude_pattern_str) = &workload.exclude_pattern {
log::info!("Exclude pattern defined, using only exclude");
log::info!("Exclude pattern: {}", exclude_pattern_str);

Expand Down Expand Up @@ -145,8 +146,14 @@ pub async fn parse_tags(workload: &Workload) -> Result<Workload, Box<dyn std::er
if tag_version > current_version {
// tag_version is greater than current_version
// Do something with this tag
println!("Tag {} is newer than current version", tag);
latest_version = tag.clone();
if latest_version.is_empty() {
log::info!("latest_version is empty - setting to tag {}", tag);
latest_version = tag.clone();
} else if tag_version > Version::parse(&strip_tag_lettings(&latest_version)).unwrap() {
log::info!("Tag {} is newer than {} current latest_version updating", tag, latest_version);
latest_version = tag.clone();
}

}
} else {
// Handle the case where the tag is not a valid SemVer format
Expand Down

0 comments on commit 705b457

Please sign in to comment.