Skip to content

Commit d794f3f

Browse files
committed
Merge branch 'provide_version'
2 parents 03e36f4 + c3c2cb6 commit d794f3f

File tree

4 files changed

+34
-22
lines changed

4 files changed

+34
-22
lines changed

src/main/kotlin/com/cosmotech/api/config/CsmOpenAPIConfiguration.kt

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import java.io.BufferedReader
1111
import org.springframework.beans.factory.annotation.Value
1212
import org.springframework.context.annotation.Bean
1313
import org.springframework.context.annotation.Configuration
14+
import com.cosmotech.api.utils.getAboutInfo
1415

1516
@Configuration
1617
open class CsmOpenAPIConfiguration(val csmPlatformProperties: CsmPlatformProperties) {
@@ -38,12 +39,8 @@ open class CsmOpenAPIConfiguration(val csmPlatformProperties: CsmPlatformPropert
3839

3940
openAPI.info.version = apiVersion
4041

41-
if (!csmPlatformProperties.vcsRef.isNullOrBlank()) {
42-
openAPI.info.description += " / ${csmPlatformProperties.vcsRef}"
43-
}
44-
if (!csmPlatformProperties.commitId.isNullOrBlank()) {
45-
openAPI.info.description += " / ${csmPlatformProperties.commitId}"
46-
}
42+
val fullVersion = getAboutInfo().getJSONObject("version").getString("full")
43+
openAPI.info.description += " ($fullVersion)"
4744

4845
// Remove any set of servers already defined in the input openapi.yaml,
4946
// so as to have the base URL auto-generated based on the incoming requests

src/main/kotlin/com/cosmotech/api/config/CsmPlatformProperties.kt

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,6 @@ import org.springframework.boot.context.properties.ConfigurationProperties
99
/** Configuration Properties for the Cosmo Tech Platform */
1010
@ConfigurationProperties(prefix = "csm.platform")
1111
data class CsmPlatformProperties(
12-
13-
/** Platform summary */
14-
val summary: String?,
15-
16-
/** Platform description */
17-
val description: String?,
18-
19-
/** Platform version (MAJOR.MINOR.PATCH) */
20-
val version: String?,
21-
22-
/** Platform exact commit ID */
23-
val commitId: String? = null,
24-
25-
/** Platform exact Version-Control System reference */
26-
val vcsRef: String? = null,
27-
2812
/** API Configuration */
2913
val api: Api,
3014

src/main/kotlin/com/cosmotech/api/security/AbstractSecurityConfiguration.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,15 @@ internal fun endpointSecurityReaders(
162162
customOrganizationViewer: String
163163
) =
164164
listOf(
165+
CsmSecurityEndpointsRolesReader(
166+
paths = listOf("/about"),
167+
roles =
168+
arrayOf(
169+
ROLE_ORGANIZATION_USER,
170+
ROLE_ORGANIZATION_VIEWER,
171+
customOrganizationUser,
172+
customOrganizationViewer),
173+
customAdmin = customOrganizationAdmin),
165174
CsmSecurityEndpointsRolesReader(
166175
paths = PATHS_CONNECTORS,
167176
roles =
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright (c) Cosmo Tech.
2+
// Licensed under the MIT license.
3+
package com.cosmotech.api.utils
4+
5+
import java.io.BufferedReader
6+
import org.json.JSONException
7+
import org.json.JSONObject
8+
9+
fun getAboutInfo(): JSONObject {
10+
val aboutJsonInputStream =
11+
object{}::class.java.getResourceAsStream("/about.json")
12+
?: throw IllegalStateException("Unable to read about info data from 'classpath:/about.json'")
13+
val aboutJsonContent = aboutJsonInputStream.use { it.bufferedReader().use(BufferedReader::readText) }
14+
15+
try {
16+
return JSONObject(aboutJsonContent)
17+
}
18+
catch (e: JSONException)
19+
{
20+
throw IllegalStateException("Unable to parse about info from 'classpath:/about.json'", e)
21+
}
22+
}

0 commit comments

Comments
 (0)