public static ResourceFileType fromFile(File file) { String ext = FilenameUtils.getExtension(file.getPath()); if (StringUtils.isNotBlank(ext)) { return fromExtension(ext); } else { throw new IllegalArgumentException(String.format("Unsupported extension '%s' for file %s. Must be one of %s", ext, file, Arrays.asList(values()))); } } }
private static ObjectMapper getObjectMapper(ResourceFileType resourceFileType) { return resourceFileType.getObjectMapper() .enable(SerializationFeature.INDENT_OUTPUT) .disable(SerializationFeature.WRITE_EMPTY_JSON_ARRAYS) .disable(SerializationFeature.WRITE_NULL_MAP_VALUES); }
public static File save(File file, Object data, ResourceFileType type) throws IOException { File output = type.addExtensionIfMissing(file); ensureDir(file); getObjectMapper(type).writeValue(output, data); return output; }
public static File save(File file, Object data) throws IOException { return save(file, data, ResourceFileType.fromFile(file)); }
protected void writeResources(KubernetesList resources, ResourceClassifier classifier, Boolean generateRoute) throws MojoExecutionException { // write kubernetes.yml / openshift.yml File resourceFileBase = new File(this.targetDir, classifier.getValue()); File file = writeResourcesIndividualAndComposite(resources, resourceFileBase, this.resourceFileType, log, generateRoute); // Attach it to the Maven reactor so that it will also get deployed projectHelper.attachArtifact(project, this.resourceFileType.getArtifactType(), classifier.getValue(), file); }
private File getImageStreamFile(BuildServiceConfig config) { return ResourceFileType.yaml.addExtensionIfMissing(new File(config.getBuildDirectory(), String.format("%s-is", config.getArtifactId()))); }
public static <T> T load(File file, Class<T> clazz) throws IOException { ResourceFileType type = ResourceFileType.fromFile(file); return load(file, clazz, type); }