Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow configure storage protocol #42

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class AzureStorageCopyStepPlugin implements StepPlugin, Describable {
public static final String ACCESS_KEY = "key"
public static final String SOURCE = "source"
public static final String DESTINATION = "destination"
public static final String DEFAULT_ENDPOINT_PROTOCOL = "defaultEndpointProtocol"

private static final int DEBUG_LEVEL = 4

Expand All @@ -52,6 +53,8 @@ class AzureStorageCopyStepPlugin implements StepPlugin, Describable {
null,null,null, renderingOptionsAuthentication))
.property(PropertyUtil.string(ACCESS_KEY, "Access Key", "Azure Storage Access Key", true,
null,null,null, renderingOptionsAuthenticationStorage))
.property(PropertyUtil.string(DEFAULT_ENDPOINT_PROTOCOL, "Endpoint Protocol", "Default Endpoint Protocol: http or https ", true,
"http", null, null, renderingOptionsAuthentication))
.property(PropertyUtil.string(SOURCE, "Source", "Azure URI or local path (azure://container/path/file.ext , file://some/path/file.ext)", true,
null,null,null, renderingOptionsConfig))
.property(PropertyUtil.string(DESTINATION, " Destination", "Azure URI or local path (azure://container/path/file.ext , file://some/path/file.ext)", true,
Expand All @@ -75,6 +78,7 @@ class AzureStorageCopyStepPlugin implements StepPlugin, Describable {
String accessKeyStoragePath=configuration.get(AzureStorageCopyStepPlugin.ACCESS_KEY)
String sourcePath=configuration.get(AzureStorageCopyStepPlugin.SOURCE)
String destinationPath=configuration.get(AzureStorageCopyStepPlugin.DESTINATION)
String defaultEndpointProtocol=configuration.get(AzureStorageCopyStepPlugin.DEFAULT_ENDPOINT_PROTOCOL)

URIParser sourceURL = new URIParser(sourcePath)
URIParser destURL = new URIParser(destinationPath)
Expand All @@ -101,8 +105,8 @@ class AzureStorageCopyStepPlugin implements StepPlugin, Describable {
AzurePluginUtil.printMessage(" Destination => " + destURL.toString(), debug, "info");
AzurePluginUtil.printMessage("---------------------------------------------------", debug, "info");

sourceEndpoint = createEndpointHandler(sourceURL, storageName, accessKey)
destEndpoint = createEndpointHandler(destURL, storageName, accessKey)
sourceEndpoint = createEndpointHandler(sourceURL, storageName, accessKey, defaultEndpointProtocol)
destEndpoint = createEndpointHandler(destURL, storageName, accessKey, defaultEndpointProtocol)


if(!sourceEndpoint.fileExists(sourceURL.getFile())){
Expand Down Expand Up @@ -139,14 +143,14 @@ class AzureStorageCopyStepPlugin implements StepPlugin, Describable {

}

private EndpointHandler createEndpointHandler(URIParser url, String storageName, String accessKey) throws IOException {
private EndpointHandler createEndpointHandler(URIParser url, String storageName, String accessKey, String defaultEndpointProtocol) throws IOException {

switch (url.getProtocol().toLowerCase()) {
case "file":
return FileEndpoint.createEndpointHandler(url);

case "azure":
return AzureEndpoint.createEndpointHandler(url, storageName, accessKey);
return AzureEndpoint.createEndpointHandler(url, storageName, accessKey, defaultEndpointProtocol);


default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import com.rundeck.plugins.azure.plugin.files.URIParser
* Created by luistoledo on 11/14/17.
*/
class AzureEndpoint {
public static EndpointHandler createEndpointHandler(final URIParser url, String storageName, String accessKey) throws IOException {
public static EndpointHandler createEndpointHandler(final URIParser url, String storageName, String accessKey, String defaultEndpointsProtocol) throws IOException {

String storageConnectionString = "DefaultEndpointsProtocol=http;AccountName=" + storageName+ ";AccountKey=" + accessKey;
String storageConnectionString = "DefaultEndpointsProtocol=" + defaultEndpointsProtocol + ";AccountName=" + storageName+ ";AccountKey=" + accessKey;

String containerName = url.getHost()

Expand Down