Skip to content

Commit

Permalink
Improved validation script
Browse files Browse the repository at this point in the history
  • Loading branch information
gastaldi committed Jun 28, 2024
1 parent 0c67585 commit 775d6cf
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
4 changes: 4 additions & 0 deletions mapping.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# This contains the authorized repository=groupId where:
# - repository is the repository where the extension is hosted
# - groupId is the groupId of the extension
quarkiverse-release/quarkus-slack=io.quarkiverse.slack
26 changes: 22 additions & 4 deletions validate_repository.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,27 @@
import java.io.File;
import java.io.FileInputStream;
import java.util.Properties;

public class validate_repository {

public static void main(String[] args) {
System.out.println(new File(System.getenv("ARTIFACT_DIR")).exists());
System.out.println("Hello, World");
public static void main(String[] args) throws Exception {
// Path artifactDir = Path.of(System.getenv("ARTIFACT_DIR"));
String repository = System.getenv("REPOSITORY");
String name = System.getenv("NAME");
// String version = System.getenv("VERSION");
// Verify if the repository pattern is valid
Properties prop = groupIdMapping();
// Check if the artifacts are from the authorized group Id
if (!prop.containsKey(repository)) {
throw new Exception("Unauthorized group Id");
}
//TODO: Perform other checks here
}

private static Properties groupIdMapping() throws Exception {
Properties prop = new Properties();
try (FileInputStream fis = new FileInputStream("mapping.properties")) {
prop.load(fis);
}
return prop;
}
}

0 comments on commit 775d6cf

Please sign in to comment.