Skip to content

Commit

Permalink
fix(titus): set default security groups for run job stage (#2036)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaslin committed Mar 2, 2018
1 parent 32020bb commit b9cefa9
Showing 1 changed file with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.netflix.spinnaker.orca.clouddriver.tasks.providers.titus;
package com.netflix.spinnaker.orca.clouddriver.tasks.providers.titus

import com.netflix.spinnaker.orca.clouddriver.tasks.job.JobRunner
import com.netflix.spinnaker.orca.pipeline.model.Stage
Expand All @@ -28,6 +28,10 @@ class TitusJobRunner implements JobRunner {
boolean katoResultExpected = false
String cloudProvider = "titus"

static final List<String> DEFAULT_SECURITY_GROUPS = ["nf-infrastructure", "nf-datacenter"]

List<String> defaultSecurityGroups = DEFAULT_SECURITY_GROUPS

@Override
List<Map> getOperations(Stage stage) {
def operation = [:]
Expand All @@ -41,7 +45,21 @@ class TitusJobRunner implements JobRunner {
operation.put('user', stage.execution.authentication?.user)
}

operation.securityGroups = operation.securityGroups ?: []

addAllNonEmpty(operation.securityGroups as List<String>, defaultSecurityGroups)

return [[(OPERATION): operation]]
}

private static void addAllNonEmpty(List<String> baseList, List<String> listToBeAdded) {
if (listToBeAdded) {
listToBeAdded.each { itemToBeAdded ->
if (itemToBeAdded) {
baseList << itemToBeAdded
}
}
}
}
}

0 comments on commit b9cefa9

Please sign in to comment.