32 import java.nio.charset.StandardCharsets;
33 import java.nio.file.Path;
34 import java.util.Optional;
35 import java.util.stream.Collectors;
36
37 class CensusInstance {
38 private final Census census;
39 private final JCheckConfiguration configuration;
40 private final Project project;
41 private final Namespace namespace;
42
43 private CensusInstance(Census census, JCheckConfiguration configuration, Project project, Namespace namespace) {
44 this.census = census;
45 this.configuration = configuration;
46 this.project = project;
47 this.namespace = namespace;
48 }
49
50 private static Repository initialize(HostedRepository repo, String ref, Path folder) {
51 try {
52 return Repository.materialize(folder, repo.url(), ref);
53 } catch (IOException e) {
54 throw new RuntimeException("Failed to retrieve census to " + folder, e);
55 }
56 }
57
58 private static Project project(JCheckConfiguration configuration, Census census) {
59 var project = census.project(configuration.general().project());
60
61 if (project == null) {
62 throw new RuntimeException("Project not found in census: " + configuration.general().project());
63 }
64
65 return project;
66 }
67
68 private static Namespace namespace(Census census, String hostNamespace) {
69 //var namespace = census.namespace(pr.repository().getNamespace());
70 var namespace = census.namespace(hostNamespace);
71 if (namespace == null) {
72 throw new RuntimeException("Namespace not found in census: " + hostNamespace);
|
32 import java.nio.charset.StandardCharsets;
33 import java.nio.file.Path;
34 import java.util.Optional;
35 import java.util.stream.Collectors;
36
37 class CensusInstance {
38 private final Census census;
39 private final JCheckConfiguration configuration;
40 private final Project project;
41 private final Namespace namespace;
42
43 private CensusInstance(Census census, JCheckConfiguration configuration, Project project, Namespace namespace) {
44 this.census = census;
45 this.configuration = configuration;
46 this.project = project;
47 this.namespace = namespace;
48 }
49
50 private static Repository initialize(HostedRepository repo, String ref, Path folder) {
51 try {
52 return Repository.materialize(folder, repo.url(), "+" + ref + ":" + "mlbridge_census_" + repo.name());
53 } catch (IOException e) {
54 throw new RuntimeException("Failed to retrieve census to " + folder, e);
55 }
56 }
57
58 private static Project project(JCheckConfiguration configuration, Census census) {
59 var project = census.project(configuration.general().project());
60
61 if (project == null) {
62 throw new RuntimeException("Project not found in census: " + configuration.general().project());
63 }
64
65 return project;
66 }
67
68 private static Namespace namespace(Census census, String hostNamespace) {
69 //var namespace = census.namespace(pr.repository().getNamespace());
70 var namespace = census.namespace(hostNamespace);
71 if (namespace == null) {
72 throw new RuntimeException("Namespace not found in census: " + hostNamespace);
|