Skip to content

Commit

Permalink
Correct 'service' and 'cluster name'
Browse files Browse the repository at this point in the history
Use case class to ensure passing correct information into function
  • Loading branch information
TomJKing committed Dec 16, 2024
1 parent 6de4913 commit e01b406
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,17 @@ class RotateClientSecrets(keycloakClient: Keycloak,

val logger: Logger = new SimpleLoggerFactory().getLogger(this.getClass.getName)

private val ecsServices: Set[(String, String)] = Set(
s"frontend_service_$stage" -> s"frontend_$stage",
s"transferservice_$stage" -> s"transferservice_service_$stage"
private case class EcsService(serviceName: String, clusterName: String)

private val ecsServices: Set[EcsService] = Set(
EcsService(s"frontend_service_$stage", s"frontend_$stage"),
EcsService(s"transferservice_service_$stage", s"transferservice_$stage")
)

private def restartEcsService(serviceName: String, clusterName: String): UpdateServiceResponse = {
private def restartEcsService(ecsService: EcsService): UpdateServiceResponse = {
val updateServiceRequest = UpdateServiceRequest.builder
.service(serviceName)
.cluster(clusterName)
.service(ecsService.serviceName)
.cluster(ecsService.clusterName)
.forceNewDeployment(true)
.build()
ecsClient.updateService(updateServiceRequest)
Expand Down Expand Up @@ -63,7 +65,7 @@ class RotateClientSecrets(keycloakClient: Keycloak,
}.toList

Try {
ecsServices.foreach(s => restartEcsService(s._1, s._2))
ecsServices.foreach(restartEcsService)
} match {
case
Failure(exception) => logger.error("Error restarting ECS", exception)
Expand Down

0 comments on commit e01b406

Please sign in to comment.