Skip to content

Commit

Permalink
Destination during fetch is not mandatory anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
manojlds committed Aug 10, 2017
1 parent d378b9f commit d2dc1ba
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
7 changes: 5 additions & 2 deletions fetch/src/main/java/com/indix/gocd/s3fetch/FetchExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.indix.gocd.utils.store.S3ArtifactStore;
import com.thoughtworks.go.plugin.api.logging.Logger;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;

import java.io.File;
import java.io.IOException;
Expand All @@ -24,9 +25,11 @@ public TaskExecutionResult execute(Config config, final Context context) {
final String bucket = getBucket(config, env);
final S3ArtifactStore store = getS3ArtifactStore(env, bucket);

context.printMessage(String.format("Getting artifacts from %s", store.pathString(artifactPathOnS3)));
String destination = String.format("%s/%s", context.getWorkingDir(), config.getDestination());
setupDestinationDirectory(destination);
context.printMessage(String.format("Getting artifacts from %s to %s", store.pathString(artifactPathOnS3), destination));
if(StringUtils.isNotBlank(config.getDestination())) {
setupDestinationDirectory(destination);
}
store.getPrefix(artifactPathOnS3, destination);
return new TaskExecutionResult(true, "Fetched all artifacts");
} catch (Exception e) {
Expand Down
2 changes: 1 addition & 1 deletion fetch/src/main/java/com/indix/gocd/s3fetch/FetchTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ private GoPluginApiResponse handleGetConfigRequest() {

HashMap destination = new HashMap();
destination.put("default-value", "");
destination.put("required", true);
destination.put("required", false);
config.put(Constants.DESTINATION, destination);

return createResponse(DefaultGoPluginApiResponse.SUCCESS_RESPONSE_CODE, config);
Expand Down
4 changes: 2 additions & 2 deletions fetch/src/main/resources/views/task.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
</div>

<div class="form_item_block">
<label>Destination directory:<span class="asterisk">*</span></label>
<input type="text" ng-model="Destination" ng-required="true">
<label>Destination directory:</label>
<input type="text" ng-model="Destination">
<span class="form_error" ng-show="GOINPUTNAME[Destination].$error.server">{{ GOINPUTNAME[Destination].$error.server }}</span>
</div>

Expand Down

0 comments on commit d2dc1ba

Please sign in to comment.