-
Notifications
You must be signed in to change notification settings - Fork 0
Add DvcService to retrieve NVR list by version from DVC repository #97
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
base: main
Are you sure you want to change the base?
Changes from 8 commits
d127ef6
d031df5
4387385
0fe3f41
b007e1b
7193aa9
549075b
4f3f2b4
8f478eb
43b333e
42031d8
1cf1ffc
67c783b
475e486
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| package com.redhat.sast.api.exceptions; | ||
|
|
||
| /** | ||
| * Exception thrown when DVC operations fail. | ||
| * This includes failures in fetching data from DVC repositories, | ||
| * parsing DVC YAML files, or DVC command execution errors. | ||
| */ | ||
| public class DvcException extends RuntimeException { | ||
|
|
||
| /** | ||
| * Constructs a new DvcException with the specified detail message. | ||
| * | ||
| * @param message the detail message | ||
| */ | ||
| public DvcException(String message) { | ||
| super(message); | ||
| } | ||
|
|
||
| /** | ||
| * Constructs a new DvcException with the specified detail message and cause. | ||
| * | ||
| * @param message the detail message | ||
| * @param cause the cause of this exception | ||
| */ | ||
| public DvcException(String message, Throwable cause) { | ||
| super(message, cause); | ||
| } | ||
| } |
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i would add some input validate, java is less forgiving compare to python
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,203 @@ | ||||||
| package com.redhat.sast.api.service; | ||||||
|
|
||||||
| import java.io.IOException; | ||||||
| import java.util.ArrayList; | ||||||
| import java.util.List; | ||||||
| import java.util.concurrent.TimeUnit; | ||||||
|
|
||||||
| import org.eclipse.microprofile.config.inject.ConfigProperty; | ||||||
| import org.yaml.snakeyaml.LoaderOptions; | ||||||
| import org.yaml.snakeyaml.Yaml; | ||||||
| import org.yaml.snakeyaml.constructor.SafeConstructor; | ||||||
|
|
||||||
| import com.redhat.sast.api.exceptions.DvcException; | ||||||
|
|
||||||
| import jakarta.enterprise.context.ApplicationScoped; | ||||||
| import lombok.extern.slf4j.Slf4j; | ||||||
|
|
||||||
| @ApplicationScoped | ||||||
| @Slf4j | ||||||
| public class DvcService { | ||||||
|
|
||||||
| @ConfigProperty(name = "dvc.repo.url") | ||||||
| String dvcRepoUrl; | ||||||
|
|
||||||
| @ConfigProperty(name = "dvc.batch.yaml.path") | ||||||
| String batchYamlPath; | ||||||
|
|
||||||
| /** | ||||||
| * Get list of NVRs from DVC repository by version tag | ||||||
| * Fetches YAML file from DVC and extracts NVR list | ||||||
| * | ||||||
| * @param version DVC version tag (e.g., "1.0.0" or "v1.0.0") | ||||||
| * @return List of package NVR strings (empty list if no NVRs found) | ||||||
| * @throws DvcException if DVC fetch fails or parsing fails | ||||||
| * @throws IllegalArgumentException if version is null or empty | ||||||
| */ | ||||||
| public List<String> getNvrListByVersion(String version) { | ||||||
|
||||||
| public List<String> getNvrListByVersion(String version) { | |
| public List<String> getNvrListByVersion(String version) { |
Maybe consider breaking the method down with some helper methods as it does several things.
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe a short comment on yaml expected structure
Uh oh!
There was an error while loading. Please reload this page.