com.pulumi.dockerbuild.Utilities Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of docker-build Show documentation
Show all versions of docker-build Show documentation
A Pulumi provider for building modern Docker images with buildx and BuildKit.
// *** WARNING: this file was generated by pulumi. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
package com.pulumi.dockerbuild;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Optional;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
import com.pulumi.core.internal.Environment;
import com.pulumi.deployment.InvokeOptions;
public class Utilities {
public static Optional getEnv(String... names) {
for (var n : names) {
var value = Environment.getEnvironmentVariable(n);
if (value.isValue()) {
return Optional.of(value.value());
}
}
return Optional.empty();
}
public static Optional getEnvBoolean(String... names) {
for (var n : names) {
var value = Environment.getBooleanEnvironmentVariable(n);
if (value.isValue()) {
return Optional.of(value.value());
}
}
return Optional.empty();
}
public static Optional getEnvInteger(String... names) {
for (var n : names) {
var value = Environment.getIntegerEnvironmentVariable(n);
if (value.isValue()) {
return Optional.of(value.value());
}
}
return Optional.empty();
}
public static Optional getEnvDouble(String... names) {
for (var n : names) {
var value = Environment.getDoubleEnvironmentVariable(n);
if (value.isValue()) {
return Optional.of(value.value());
}
}
return Optional.empty();
}
public static InvokeOptions withVersion(@Nullable InvokeOptions options) {
if (options != null && options.getVersion().isPresent()) {
return options;
}
return new InvokeOptions(
options == null ? null : options.getParent().orElse(null),
options == null ? null : options.getProvider().orElse(null),
getVersion()
);
}
private static final String version;
public static String getVersion() {
return version;
}
static {
var resourceName = "com/pulumi/docker-build/version.txt";
var versionFile = Utilities.class.getClassLoader().getResourceAsStream(resourceName);
if (versionFile == null) {
throw new IllegalStateException(
String.format("expected resource '%s' on Classpath, not found", resourceName)
);
}
version = new BufferedReader(new InputStreamReader(versionFile))
.lines()
.collect(Collectors.joining("\n"))
.trim();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy