public static ImageReference getGeneratedTargetDockerTag(
      @Nullable String targetImage,
      ProjectProperties projectProperties,
      HelpfulSuggestions helpfulSuggestions)
      throws InvalidImageReferenceException {
    String generatedName = projectProperties.getName();
    String generatedTag =
        projectProperties.getVersion().equals("unspecified")
            ? "latest"
            : projectProperties.getVersion();
    if (Strings.isNullOrEmpty(targetImage)) {
      projectProperties.log(
          LogEvent.lifecycle(helpfulSuggestions.forGeneratedTag(generatedName, generatedTag)));

      // Try to parse generated tag to verify that project name and version are valid (throws an
      // exception if parse fails)
      ImageReference.parse(generatedName + ":" + generatedTag);
      return ImageReference.of(null, generatedName, generatedTag);
    } else {
      return ImageReference.parse(targetImage);
    }
  }
Returns an {@link ImageReference} parsed from the configured target image, or one of the form
{@code project-name:project-version} if target image is not configured.

@param targetImage the configured target image reference
@param projectProperties the {@link ProjectProperties} providing the project name, version, and
    log event handler
@param helpfulSuggestions used for generating the message notifying the user of the generated
    tag
@return an {@link ImageReference} parsed from the configured target image, or one of the form
    {@code project-name:project-version} if target image is not configured
@throws InvalidImageReferenceException if the configured or generated image reference is
    invalid
jib-plugins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/ConfigurationPropertyValidator.java