-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathActiveProfilesResolver.kt
More file actions
33 lines (27 loc) · 967 Bytes
/
ActiveProfilesResolver.kt
File metadata and controls
33 lines (27 loc) · 967 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package com.dangle.api.common.phase
import org.springframework.core.env.Environment
import org.springframework.stereotype.Component
@Component
class ActiveProfilesResolver(
env: Environment
){
private val activeProfilePhases = ActiveProfilePhase.values().map { it.phase }.toSet()
private val currentProfiles = env.activeProfiles
.filter { it in activeProfilePhases }
.associateBy{ it }
.ifEmpty { mapOf(ActiveProfilePhase.LOCAL.phase to ActiveProfilePhase.LOCAL) }
fun isPrd() : Boolean{
return currentProfiles[ActiveProfilePhase.PRD.phase] != null
}
fun isDev() : Boolean{
return currentProfiles[ActiveProfilePhase.DEV.phase] != null
}
fun isLocal(): Boolean{
return currentProfiles[ActiveProfilePhase.LOCAL.phase] != null
}
private enum class ActiveProfilePhase(val phase: String) {
LOCAL("local"),
DEV("dev"),
PRD("prd"),
}
}