Skip to content

Commit

Permalink
Clean up spec file handling
Browse files Browse the repository at this point in the history
  • Loading branch information
grafnu committed Feb 3, 2025
1 parent 9d648e4 commit d07d984
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions common/src/main/java/com/google/udmi/util/SiteModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,12 @@ public SiteModel(String sitePath, ExecutionConfiguration config) {
public SiteModel(String specPath, Supplier<String> specSupplier,
ExecutionConfiguration overrides) {
File specFile = new File(requireNonNull(specPath, "site model not defined"));
boolean specIsFile = specFile.isFile();
siteConf = specIsFile ? specFile : cloudConfigPath(specFile);
boolean specIsDirectory = specFile.isDirectory();
siteConf = specIsDirectory ? cloudConfigPath(specFile) : specFile;
if (!siteConf.exists()) {
throw new RuntimeException("File not found: " + siteConf.getAbsolutePath());
}
specMatcher = (specIsFile || specSupplier == null) ? null : extractSpec(specSupplier.get());
specMatcher = ifNotNullGet(specSupplier, spec -> extractSpec(spec.get()));
exeConfig = loadSiteConfig();
sitePath = ofNullable(exeConfig.site_model).map(f -> maybeRelativeTo(f, exeConfig.src_file))
.orElse(siteConf.getParent());
Expand Down Expand Up @@ -596,6 +596,9 @@ public boolean deviceExists(String deviceId) {
}

private Matcher extractSpec(String projectSpec) {
if (projectSpec == null) {
return null;
}
Matcher matcher = SPEC_PATTERN.matcher(projectSpec);
if (!matcher.matches()) {
throw new RuntimeException(
Expand Down

0 comments on commit d07d984

Please sign in to comment.