Skip to content
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
* Do not retrieve components from Jira when using an alternate Jira project and not generating documentation ([#1211](https://github.com/opendevstack/ods-jenkins-shared-library/pull/1211))

### Fixed
* Error generating TIR for infra components ([#1216](https://github.com/opendevstack/ods-jenkins-shared-library/pull/1216))
* Use N/A if there isn't system requirements in DTR ([#1214](https://github.com/opendevstack/ods-jenkins-shared-library/pull/1214))
* Remove missing tests count ([#1213](https://github.com/opendevstack/ods-jenkins-shared-library/pull/1213))

Expand Down
10 changes: 7 additions & 3 deletions src/org/ods/orchestration/usecase/LeVADocumentUseCase.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -1143,7 +1143,11 @@ class LeVADocumentUseCase extends DocGenUseCase {
*/
protected static Map<String, Object> prepareDeploymentMeanInfo(Map<String, Map<String, Object>> deployments, String targetEnvironment) {
Map<String, Object> deploymentMean =
deployments.find { it.key.endsWith('-deploymentMean') }.value
deployments?.find { it.key.endsWith('-deploymentMean') }?.value

if (!deploymentMean) {
return [:]
}

if (deploymentMean.type == 'tailor') {
return formatTIRTailorDeploymentMean(deploymentMean)
Expand All @@ -1162,8 +1166,8 @@ class LeVADocumentUseCase extends DocGenUseCase {
*/
protected static Map<String, Map<String, Object>> prepareDeploymentInfo(Map<String, Map<String, Object>> deployments) {
return deployments
.findAll { ! it.key.endsWith('-deploymentMean') }
.collectEntries { String deploymentName, Map<String, Object> deployment ->
?.findAll { ! it.key.endsWith('-deploymentMean') }
?.collectEntries { String deploymentName, Map<String, Object> deployment ->
def filteredFields = deployment.findAll { k, v -> k != 'podName' }
return [(deploymentName): filteredFields]
} as Map<String, Map<String, Object>>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1284,6 +1284,22 @@ class LeVADocumentUseCaseSpec extends SpecHelper {
true | FixtureHelper.createTIRDataTailor() | FixtureHelper.createTIRRepoTailor()
}

def "createTIR for infra component"() {
when: 'Preparing deploymentMean info for infra component'
def deploymentMeanInfo = usecase.prepareDeploymentMeanInfo(null, 'dev')

then: 'The obtained info is null or empty, but no exception is thrown'
noExceptionThrown()
!deploymentMeanInfo

when: 'Preparing deployment info for infra component'
def deploymentInfo = usecase.prepareDeploymentInfo(null)

then: 'The obtained info is null or empty, but no exception is thrown'
noExceptionThrown()
!deploymentInfo
}

def "assemble deploymentMean and deploymentInfo for TIR with helm"() {
given:
def deployments = FixtureHelper.createTIRRepoHelm().data.openshift.deployments
Expand Down
35 changes: 35 additions & 0 deletions test/groovy/util/FixtureHelper.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -918,6 +918,41 @@ class FixtureHelper {
]
}

static Map createTIRRepoInfra() {
[
'include' : true,
'metadata' : [
'supplier' : 'IT INF IAS',
'name' : 'MyLambda',
'description': 'A lambda intended to run in AWS',
'type' : 'ods-infra',
'version' : '4.x',
],
'data' : [
'git' : [
'previousSucessfulCommit': 'b00012345bcdef',
'baseTag' : '',
'commit' : 'a00012345bcdef',
'previousCommit' : 'b00012345bcdef',
'targetTag' : '',
'branch' : 'master',
'url' : 'https://bitbucket-myodsproject-cd.ocp.mycompany.com/scm/myodsproject/myodsproject-mylambda.git',
],
'previousSucessfulCommit': 'c00012345bcdef',
'documents' : [
],
],
'doInstall' : true,
'pipelineConfig': [
'dependencies': [],
],
'defaultBranch' : 'master',
'id' : 'mylambda-infra',
'type' : 'ods-infra',
'url' : 'https://bitbucket-myodsproject-cd.ocp.mycompany.com/scm/myodsproject/myodsproject-mylambda.git',
]
}

static Map createHelmCmdStatusMap() {
[
'info' : [
Expand Down