Skip to content

Commit b6edaad

Browse files
committed
Replace resource-name lable by realm-id
1 parent 0b2c425 commit b6edaad

4 files changed

Lines changed: 13 additions & 16 deletions

File tree

src/main/kotlin/eu/openanalytics/shinyproxyoperator/components/LabelFactory.kt

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,33 +25,25 @@ import eu.openanalytics.shinyproxyoperator.crd.ShinyProxyInstance
2525

2626
object LabelFactory {
2727

28-
fun labelsForCurrentShinyProxyInstance(shinyProxy: ShinyProxy): Map<String, String> {
29-
return mapOf(
30-
APP_LABEL to APP_LABEL_VALUE,
31-
NAME_LABEL to shinyProxy.metadata.name,
32-
INSTANCE_LABEL to shinyProxy.hashOfCurrentSpec
33-
)
34-
}
35-
3628
fun labelsForShinyProxyInstance(shinyProxy: ShinyProxy, shinyProxyInstance: ShinyProxyInstance): Map<String, String> {
3729
val hashOfSpec = shinyProxyInstance.hashOfSpec
3830
return mapOf(
3931
APP_LABEL to APP_LABEL_VALUE,
40-
NAME_LABEL to shinyProxy.metadata.name,
32+
REALM_ID_LABEL to shinyProxy.realmId,
4133
INSTANCE_LABEL to hashOfSpec
4234
)
4335
}
4436

4537
fun labelsForShinyProxy(shinyProxy: ShinyProxy): Map<String, String> {
4638
return mapOf(
4739
APP_LABEL to APP_LABEL_VALUE,
48-
NAME_LABEL to shinyProxy.metadata.name
40+
REALM_ID_LABEL to shinyProxy.realmId
4941
)
5042
}
5143

5244
const val APP_LABEL = "app"
5345
const val APP_LABEL_VALUE = "shinyproxy"
54-
const val NAME_LABEL = "openanalytics.eu/sp-resource-name"
46+
const val REALM_ID_LABEL = "openanalytics.eu/sp-realm-id"
5547
const val INSTANCE_LABEL = "openanalytics.eu/sp-instance"
5648
const val LATEST_INSTANCE_LABEL = "openanalytics.eu/sp-latest-instance"
5749
const val PROXIED_APP = "openanalytics.eu/sp-proxied-app"

src/main/kotlin/eu/openanalytics/shinyproxyoperator/components/PodTemplateSpecFactory.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class PodTemplateSpecFactory {
7474
.build(),
7575
EnvVarBuilder()
7676
.withName("PROXY_REALM_ID")
77-
.withValue(shinyProxy.metadata.name + '-' + shinyProxy.metadata.namespace)
77+
.withValue(shinyProxy.realmId)
7878
.build()))
7979
.withVolumeMounts(VolumeMountBuilder()
8080
.withName("config-volume")

src/main/kotlin/eu/openanalytics/shinyproxyoperator/crd/ShinyProxy.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,11 @@ class ShinyProxy : CustomResource<JsonNode, ShinyProxyStatus>(), Namespaced {
156156
return@lazy specAsYaml.sha1()
157157
}
158158

159+
@get:JsonIgnore
160+
val realmId: String by lazy {
161+
return@lazy "${metadata.name}-${metadata.namespace}"
162+
}
163+
159164

160165
fun logPrefix(shinyProxyInstance: ShinyProxyInstance): String {
161166
return "[${metadata.namespace}/${metadata.name}/${shinyProxyInstance.hashOfSpec}]"

src/test/kotlin/eu/openanalytics/shinyproxyoperator/helpers/ShinyProxyTestInstance.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class ShinyProxyTestInstance(private val namespace: String,
106106

107107
assertEquals(mapOf(
108108
LabelFactory.APP_LABEL to LabelFactory.APP_LABEL_VALUE,
109-
LabelFactory.NAME_LABEL to sp.metadata.name
109+
LabelFactory.REALM_ID_LABEL to sp.metadata.name
110110
), ingress.metadata.labels)
111111

112112
assertOwnerReferenceIsCorrect(ingress, sp)
@@ -131,7 +131,7 @@ class ShinyProxyTestInstance(private val namespace: String,
131131

132132
assertEquals(mapOf(
133133
LabelFactory.APP_LABEL to LabelFactory.APP_LABEL_VALUE,
134-
LabelFactory.NAME_LABEL to sp.metadata.name,
134+
LabelFactory.REALM_ID_LABEL to sp.metadata.name,
135135
LabelFactory.LATEST_INSTANCE_LABEL to sp.status.latestInstance()!!.hashOfSpec
136136
), service.metadata.labels)
137137

@@ -143,7 +143,7 @@ class ShinyProxyTestInstance(private val namespace: String,
143143
assertEquals(IntOrString(8080), service.spec.ports[0].targetPort)
144144
assertEquals(mapOf(
145145
LabelFactory.APP_LABEL to LabelFactory.APP_LABEL_VALUE,
146-
LabelFactory.NAME_LABEL to sp.metadata.name,
146+
LabelFactory.REALM_ID_LABEL to sp.metadata.name,
147147
LabelFactory.INSTANCE_LABEL to sp.status.latestInstance()!!.hashOfSpec // TODO
148148
), service.spec.selector)
149149

@@ -223,7 +223,7 @@ class ShinyProxyTestInstance(private val namespace: String,
223223
fun assertLabelsAreCorrect(resource: HasMetadata, sp: ShinyProxy) {
224224
assertEquals(mapOf(
225225
LabelFactory.APP_LABEL to LabelFactory.APP_LABEL_VALUE,
226-
LabelFactory.NAME_LABEL to sp.metadata.name,
226+
LabelFactory.REALM_ID_LABEL to sp.metadata.name,
227227
LabelFactory.INSTANCE_LABEL to hash
228228
), resource.metadata.labels)
229229
}

0 commit comments

Comments
 (0)