kopia lustrzana https://github.com/gaul/s3proxy
rodzic
c2ec948968
commit
26dd4a46e9
|
@ -17,13 +17,12 @@
|
||||||
package org.gaul.s3proxy;
|
package org.gaul.s3proxy;
|
||||||
|
|
||||||
import java.io.Console;
|
import java.io.Console;
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.nio.file.FileSystems;
|
import java.nio.file.FileSystems;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.nio.file.PathMatcher;
|
import java.nio.file.PathMatcher;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
@ -39,7 +38,7 @@ import java.util.regex.Pattern;
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
import com.google.common.collect.ImmutableBiMap;
|
import com.google.common.collect.ImmutableBiMap;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.io.Files;
|
import com.google.common.io.MoreFiles;
|
||||||
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||||
|
|
||||||
import org.jclouds.Constants;
|
import org.jclouds.Constants;
|
||||||
|
@ -68,7 +67,7 @@ public final class Main {
|
||||||
private static final class Options {
|
private static final class Options {
|
||||||
@Option(name = "--properties",
|
@Option(name = "--properties",
|
||||||
usage = "S3Proxy configuration (required, multiple allowed)")
|
usage = "S3Proxy configuration (required, multiple allowed)")
|
||||||
private List<File> propertiesFiles = new ArrayList<>();
|
private List<Path> properties = new ArrayList<>();
|
||||||
|
|
||||||
@Option(name = "--version", usage = "display version")
|
@Option(name = "--version", usage = "display version")
|
||||||
private boolean version;
|
private boolean version;
|
||||||
|
@ -93,7 +92,7 @@ public final class Main {
|
||||||
System.err.println(
|
System.err.println(
|
||||||
Main.class.getPackage().getImplementationVersion());
|
Main.class.getPackage().getImplementationVersion());
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
} else if (options.propertiesFiles.isEmpty()) {
|
} else if (options.properties.isEmpty()) {
|
||||||
usage(parser);
|
usage(parser);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,9 +109,9 @@ public final class Main {
|
||||||
.<PathMatcher, Map.Entry<String, BlobStore>>builder();
|
.<PathMatcher, Map.Entry<String, BlobStore>>builder();
|
||||||
Set<String> locatorGlobs = new HashSet<>();
|
Set<String> locatorGlobs = new HashSet<>();
|
||||||
Set<String> parsedIdentities = new HashSet<>();
|
Set<String> parsedIdentities = new HashSet<>();
|
||||||
for (File propertiesFile : options.propertiesFiles) {
|
for (var path : options.properties) {
|
||||||
var properties = new Properties();
|
var properties = new Properties();
|
||||||
try (InputStream is = new FileInputStream(propertiesFile)) {
|
try (var is = Files.newInputStream(path)) {
|
||||||
properties.load(is);
|
properties.load(is);
|
||||||
}
|
}
|
||||||
properties.putAll(System.getProperties());
|
properties.putAll(System.getProperties());
|
||||||
|
@ -350,9 +349,9 @@ public final class Main {
|
||||||
identity = Strings.nullToEmpty(identity);
|
identity = Strings.nullToEmpty(identity);
|
||||||
credential = Strings.nullToEmpty(credential);
|
credential = Strings.nullToEmpty(credential);
|
||||||
} else if (provider.equals("google-cloud-storage")) {
|
} else if (provider.equals("google-cloud-storage")) {
|
||||||
var credentialFile = new File(credential);
|
var path = FileSystems.getDefault().getPath(credential);
|
||||||
if (credentialFile.exists()) {
|
if (Files.exists(path)) {
|
||||||
credential = Files.asCharSource(credentialFile,
|
credential = MoreFiles.asCharSource(path,
|
||||||
StandardCharsets.UTF_8).read();
|
StandardCharsets.UTF_8).read();
|
||||||
}
|
}
|
||||||
properties.remove(Constants.PROPERTY_CREDENTIAL);
|
properties.remove(Constants.PROPERTY_CREDENTIAL);
|
||||||
|
|
|
@ -16,11 +16,12 @@
|
||||||
|
|
||||||
package org.gaul.s3proxy;
|
package org.gaul.s3proxy;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.FileSystems;
|
||||||
|
import java.nio.file.Files;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
@ -29,7 +30,7 @@ import com.google.common.base.Strings;
|
||||||
import com.google.common.hash.HashFunction;
|
import com.google.common.hash.HashFunction;
|
||||||
import com.google.common.hash.Hashing;
|
import com.google.common.hash.Hashing;
|
||||||
import com.google.common.io.ByteSource;
|
import com.google.common.io.ByteSource;
|
||||||
import com.google.common.io.Files;
|
import com.google.common.io.MoreFiles;
|
||||||
import com.google.common.io.Resources;
|
import com.google.common.io.Resources;
|
||||||
|
|
||||||
import org.eclipse.jetty.util.component.AbstractLifeCycle;
|
import org.eclipse.jetty.util.component.AbstractLifeCycle;
|
||||||
|
@ -165,9 +166,9 @@ final class TestUtils {
|
||||||
String credential = info.getProperties().getProperty(
|
String credential = info.getProperties().getProperty(
|
||||||
Constants.PROPERTY_CREDENTIAL);
|
Constants.PROPERTY_CREDENTIAL);
|
||||||
if (provider.equals("google-cloud-storage")) {
|
if (provider.equals("google-cloud-storage")) {
|
||||||
var credentialFile = new File(credential);
|
var path = FileSystems.getDefault().getPath(credential);
|
||||||
if (credentialFile.exists()) {
|
if (Files.exists(path)) {
|
||||||
credential = Files.asCharSource(credentialFile,
|
credential = MoreFiles.asCharSource(path,
|
||||||
StandardCharsets.UTF_8).read();
|
StandardCharsets.UTF_8).read();
|
||||||
}
|
}
|
||||||
info.getProperties().remove(Constants.PROPERTY_CREDENTIAL);
|
info.getProperties().remove(Constants.PROPERTY_CREDENTIAL);
|
||||||
|
|
Ładowanie…
Reference in New Issue