@VisibleForTesting
  static GlobalConfig readConfig(Path configDir) throws IOException, InvalidGlobalConfigException {
    Path configFile = configDir.resolve(CONFIG_FILENAME);

    try {
      if (Files.exists(configFile)) {
        GlobalConfigTemplate configJson =
            JsonTemplateMapper.readJsonFromFile(configFile, GlobalConfigTemplate.class);
        return from(configJson);
      }

      // Generate config file if it doesn't exist
      Files.createDirectories(configDir);
      Path tempConfigFile = Files.createTempFile(configDir, CONFIG_FILENAME, null);
      tempConfigFile.toFile().deleteOnExit();

      GlobalConfigTemplate configJson = new GlobalConfigTemplate();
      try (OutputStream outputStream = Files.newOutputStream(tempConfigFile)) {
        JsonTemplateMapper.writeTo(configJson, outputStream);
        Files.move(tempConfigFile, configFile);
        return from(configJson);

      } catch (FileAlreadyExistsException ex) {
        // Perhaps created concurrently. Read again.
        return readConfig(configDir);
      }

    } catch (InvalidGlobalConfigException ex) {
      throw new InvalidGlobalConfigException(
          ex.getMessage()
              + "; see https://github.com/GoogleContainerTools/jib/blob/master/docs/faq.md#where-is-the-global-jib-configuration-file-and-how-i-can-configure-it "
              + "to fix or you may need to delete "
              + configFile);

    } catch (IOException ex) {
      throw new IOException(
          "Failed to create, open, or parse global Jib config file; see "
              + "https://github.com/GoogleContainerTools/jib/blob/master/docs/faq.md#where-is-the-global-jib-configuration-file-and-how-i-can-configure-it "
              + "to fix or you may need to delete "
              + configFile,
          ex);
    }
  }
Represents read-only Jib global configuration.
jib-plugins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/globalconfig/GlobalConfig.java