Pārlūkot izejas kodu

write software versions file if it does not exist

tags/v1.1.4
Jonathan Cobb pirms 4 gadiem
vecāks
revīzija
47e5852598
3 mainītis faili ar 15 papildinājumiem un 4 dzēšanām
  1. +11
    -3
      bubble-server/src/main/java/bubble/server/BubbleConfiguration.java
  2. +4
    -0
      bubble-server/src/main/java/bubble/service/packer/PackerJob.java
  3. +0
    -1
      bubble-server/src/main/java/bubble/service/packer/PackerService.java

+ 11
- 3
bubble-server/src/main/java/bubble/server/BubbleConfiguration.java Parādīt failu

@@ -52,9 +52,7 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.beans.Transient;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.*;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
@@ -185,6 +183,16 @@ public class BubbleConfiguration extends PgRestServerConfiguration
}
}

public void saveSoftwareVersions (Properties softwareVersions) {
if (!SOFTWARE_VERSIONS_FILE.exists()) {
try (OutputStream out = new FileOutputStream(SOFTWARE_VERSIONS_FILE)) {
softwareVersions.store(out, null);
} catch (Exception e) {
log.error("saveSoftwareVersions: "+shortError(e));
}
}
}

@Setter private String localStorageDir = DEFAULT_LOCAL_STORAGE_DIR;
public String getLocalStorageDir () { return empty(localStorageDir) ? DEFAULT_LOCAL_STORAGE_DIR : localStorageDir; }



+ 4
- 0
bubble-server/src/main/java/bubble/service/packer/PackerJob.java Parādīt failu

@@ -295,6 +295,7 @@ public class PackerJob implements Callable<List<PackerImage>> {
private void writeBubbleVersions(TempDir tempDir, Map<String, String> versions) {
final File varsDir = mkdirOrDie(abs(tempDir) + "/roles/"+ROLE_BUBBLE+"/vars");
final StringBuilder b = new StringBuilder();
final Properties softwareProps = new Properties();
for (Map.Entry<String, String> var : versions.entrySet()) {
final String roleName = var.getKey();
final String version = var.getValue().trim();
@@ -302,8 +303,11 @@ public class PackerJob implements Callable<List<PackerImage>> {
final String hash = packerService.getSoftwareHash(roleName, version);
b.append(roleBase).append("_version : '").append(version).append("'\n")
.append(roleBase).append("_sha : '").append(hash).append("'\n");
softwareProps.setProperty(roleBase+"_version", version);
softwareProps.setProperty(roleBase+"_sha", hash);
}
FileUtil.toFileOrDie(new File(varsDir, "main.yml"), b.toString());
configuration.saveSoftwareVersions(softwareProps);
}

private Map<String, String> getSoftwareVersion(String roleName, TempDir tempDir) throws IOException {


+ 0
- 1
bubble-server/src/main/java/bubble/service/packer/PackerService.java Parādīt failu

@@ -165,7 +165,6 @@ public class PackerService {
case ROLE_DNSCRYPT: return "";
default: return die("getSoftwareSuffix: unrecognized roleName: "+roleName);
}

}

}

Notiek ielāde…
Atcelt
Saglabāt