Skip to content

Commit

Permalink
Merge pull request #313 from saagie/fix-issue-287
Browse files Browse the repository at this point in the history
Fix docker export v1 problem
  • Loading branch information
medamineziraoui authored Sep 3, 2020
2 parents 9b9ff4d + e019809 commit cf1d9d1
Show file tree
Hide file tree
Showing 4 changed files with 230 additions and 223 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1204,7 +1204,7 @@ class SaagieClient {
def resultTechnologiesVersions = TechnologyService.instance.getTechnologyVersions(technologyV2Id)
def technologyV2Version = null
if (resultTechnologiesVersions) {
technologyV2Version = TechnologyService.instance.getMostRelevantTechnologyVersion(technologyV2Id, versionV1, extraTechV1)
technologyV2Version = TechnologyService.instance.getMostRelevantTechnologyVersion(technologyV2Id, versionV1, extraTechV1, resultTechnologiesVersions)
}

return technologyV2Version
Expand Down Expand Up @@ -1487,10 +1487,6 @@ class SaagieClient {
variablesListRequest = saagieUtils.getProjectEnvironmentVariables(configuration.project.id)
}
def listVariables = getListOfVariablesFromRequest(variablesListRequest)
if (listVariables.size().equals(0)) {
println "WARNING: No environment variable found on the targeted platform with scope ${configuration.env.scope}"
return null
}

if (configuration.env.scope.equals(EnvVarScopeTypeEnum.project.name())) {
listVariables = listVariables.findAll {
Expand All @@ -1500,6 +1496,11 @@ class SaagieClient {
}
}

if (listVariables.size().equals(0)) {
logger.warn("WARNING: No environment variable found on the targeted platform with scope ${configuration.env.scope}")
return null
}

if (checkIfEnvDefinedNamesIsValidFromConfiguration()) {
listVariables = listVariables.findAll {
configuration.env.name.contains(it.name)
Expand Down Expand Up @@ -1557,10 +1558,6 @@ class SaagieClient {
tryCatchClosure({

listVariables = getAllVariablesFromV1()
if (listVariables.size().equals(0)) {
println "WARNING: No environment variable found on the targeted platform with scope ${configuration.env.scope}"
return null
}

if (!configuration.env.include_all_var && configuration.env.name) {
configuration.env.name.forEach {
Expand All @@ -1576,6 +1573,11 @@ class SaagieClient {
}
}

if (listVariables.size().equals(0)) {
logger.warn("WARNING: No environment variable found on the targeted platform with scope ${configuration.env.scope}")
return null
}

def exportVariablesV1 = []

listVariables.collect { element ->
Expand Down Expand Up @@ -1861,20 +1863,6 @@ class SaagieClient {

if (variablesConfigFromExportedZip?.variables && response.status == ResponseStatusEnum.success.name) {

variablesConfigFromExportedZip?.variables?.values()?.forEach { variable ->
def listVariablesByNameAndId = VariableService.instance.getVariableList(variable.configOverride, configuration.project.id, this.&getVariableEnvironmentFromList)
def foundVariable = listVariablesByNameAndId.first().find { it ->
def nameIsEqual = variable.configOverride.name.equals(it.name) ;
def idIsSetOrIdDifferent = (!variable.configOverride.id || variable.configOverride.id != it.id) ;
def variableScopeIsTheSame = variable.configOverride.scope.equals(it.scope)
return nameIsEqual && idIsSetOrIdDifferent && variableScopeIsTheSame
}

if (foundVariable) {
throw new GradleException("Environmnent variable name : ${variable.configOverride.name} already exist in the targeted platform")
}
}

ImportVariableService.importAndCreateVariables(
variablesConfigFromExportedZip.variables,
configuration,
Expand Down
Loading

0 comments on commit cf1d9d1

Please sign in to comment.