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

RSE-812: Fix: not importing logs from azure #37

Merged
merged 4 commits into from
Oct 26, 2023
Merged
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
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ configurations {

dependencies {
implementation 'org.codehaus.groovy:groovy-all:3.0.9'
implementation group: 'org.rundeck', name: 'rundeck-core', version: '4.3.+'
implementation group: 'org.rundeck', name: 'rundeck-core', version: '4.17.2-rc1-20231025'

pluginLibs (group: 'com.microsoft.azure', name: 'azure', version: '1.41.4'){
exclude group: "com.fasterxml.jackson.core"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,14 @@ class AzureFileStoragePlugin implements ExecutionFileStoragePlugin, ExecutionMul
container.createIfNotExists()
}

/**
* @param context execution context
* @return true if the given context has the expanded path of the log files in the `outputfilepath` variable
*/
protected static boolean isImportedExecution(Map<String, ?> context){
L2JE marked this conversation as resolved.
Show resolved Hide resolved
return context != null && context.get("isRemoteFilePath") != null && context.get("isRemoteFilePath") == "true"
}

@Override
boolean isAvailable(String filetype) throws ExecutionFileStorageException {
try {
Expand Down Expand Up @@ -225,7 +233,10 @@ class AzureFileStoragePlugin implements ExecutionFileStoragePlugin, ExecutionMul
*/
static String expandPath(String pathFormat, Map<String, ?> context) {
String result = pathFormat.replaceAll("^/+", "");
if (null != context) {

if(isImportedExecution(context))
result = String.valueOf(context.get("outputfilepath").toString())
else if (null != context) {
result = DataContextUtils.replaceDataReferences(
result,
DataContextUtils.addContext("job", stringMap(context), new HashMap<>()),
Expand All @@ -252,12 +263,16 @@ class AzureFileStoragePlugin implements ExecutionFileStoragePlugin, ExecutionMul
}

String getFileName(String fileType){
String executionId=context.get(META_EXECID)
String project=context.get(META_PROJECT)

String fileName="${project}/${executionId}.${fileType}"
String fileName
if(isImportedExecution(this.context))
fileName = expandedPath.substring(expandedPath.indexOf("/"), expandedPath.length()).toLowerCase()
else{
String executionId=context.get(META_EXECID)
String project=context.get(META_PROJECT)
fileName = "${project}/${executionId}"
}

return fileName
return fileName + ".${fileType}"
}


Expand Down Expand Up @@ -299,5 +314,8 @@ class AzureFileStoragePlugin implements ExecutionFileStoragePlugin, ExecutionMul
return blob
}


@Override
public String getConfiguredPathTemplate(){
return this.path;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,21 @@ class AzureFileStoragePluginSpec extends Specification{
thrown IllegalArgumentException
}

def "return true if it was initialized with an imported execution"(){
when:
boolean isImportedExecution = AzureFileStoragePlugin.isImportedExecution(context)

then:
isImportedExecution == expected

where:
context | expected
['isRemoteFilePath': 'asd'] | false
['isRemoteFilePath': 'true'] | true
[:] | false
null | false
}


private HashMap<String, Object> testContext() {
HashMap<String, Object> stringHashMap = new HashMap<String, Object>();
Expand Down
Loading