Skip to content

Commit

Permalink
OCTOPUS-497 Bump CRS version from 2.0.10 to 2.0.11 (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
ozonophore authored Sep 26, 2023
1 parent d50c6f9 commit e2676bb
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 19 deletions.
7 changes: 1 addition & 6 deletions components-registry/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,7 @@
<dependency>
<groupId>org.octopusden.octopus.infrastructure</groupId>
<artifactId>components-registry-service-client</artifactId>
<version>2.0.10</version>
</dependency>
<dependency>
<groupId>org.octopusden.octopus.infrastructure</groupId>
<artifactId>components-registry-service-core</artifactId>
<version>2.0.10</version>
<version>2.0.11</version>
</dependency>
<dependency>
<groupId>io.github.openfeign</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import org.octopusden.octopus.jira.model.VCSSettings
import org.octopusden.octopus.releng.dto.ComponentVersion
import org.octopusden.octopus.releng.dto.JiraComponentVersion
import java.util.Optional
import org.octopusden.octopus.releng.JiraComponentVersionFormatter
import org.octopusden.releng.versions.VersionNames

interface ComponentRegistryService {

Expand Down Expand Up @@ -54,4 +56,8 @@ interface ComponentRegistryService {
fun getDetailedComponentVersions(component: String, versions: Set<String>): DetailedComponentVersions

fun checkCacheActualityAndClean(forceClean: Boolean = false)

fun getVersionNames(): VersionNames

fun getComponentVersionFormatter(): JiraComponentVersionFormatter
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,33 @@ import com.atlassian.cache.CacheManager
import com.atlassian.jira.project.Project
import com.atlassian.jira.project.version.Version
import feign.FeignException
import java.util.Date
import java.util.Optional
import java.util.SortedSet
import org.octopusden.octopus.components.registry.client.ComponentsRegistryServiceClient
import org.octopusden.octopus.components.registry.core.dto.*
import org.octopusden.octopus.components.registry.core.dto.ComponentInfoDTO
import org.octopusden.octopus.components.registry.core.dto.ComponentVersionFormatDTO
import org.octopusden.octopus.components.registry.core.dto.DistributionDTO
import org.octopusden.octopus.components.registry.core.dto.JiraComponentDTO
import org.octopusden.octopus.components.registry.core.dto.JiraComponentVersionDTO
import org.octopusden.octopus.components.registry.core.dto.JiraComponentVersionRangeDTO
import org.octopusden.octopus.components.registry.core.dto.VCSSettingsDTO
import org.octopusden.octopus.components.registry.core.dto.VcsRootDateDTO
import org.octopusden.octopus.components.registry.core.dto.VersionControlSystemRootDTO
import org.octopusden.octopus.components.registry.core.dto.VersionNamesDTO
import org.octopusden.octopus.components.registry.core.dto.VersionRequest
import org.octopusden.octopus.jira.exception.JiraApplicationException
import org.octopusden.octopus.jira.model.*
import org.octopusden.octopus.jira.model.Component
import org.octopusden.octopus.jira.model.ComponentRegistryVersion
import org.octopusden.octopus.jira.model.DetailedComponentVersion
import org.octopusden.octopus.jira.model.DetailedComponentVersions
import org.octopusden.octopus.jira.model.Distribution
import org.octopusden.octopus.jira.model.JiraComponentVersionRange
import org.octopusden.octopus.jira.model.JiraProjectVersion
import org.octopusden.octopus.jira.model.RepositoryType
import org.octopusden.octopus.jira.model.VCSSettings
import org.octopusden.octopus.jira.model.VcsRootLastChangeDate
import org.octopusden.octopus.jira.model.VersionControlSystemRoot
import org.octopusden.octopus.releng.JiraComponentVersionFormatter
import org.octopusden.octopus.releng.dto.ComponentInfo
import org.octopusden.octopus.releng.dto.ComponentVersion
Expand All @@ -21,7 +39,6 @@ import org.octopusden.octopus.releng.dto.JiraComponentVersion
import org.octopusden.releng.versions.ComponentVersionFormat
import org.octopusden.releng.versions.VersionNames
import org.slf4j.LoggerFactory
import java.util.*
import javax.inject.Inject
import javax.inject.Named

Expand All @@ -31,7 +48,9 @@ class ComponentRegistryServiceImpl @Inject constructor(
private val cacheManager: CacheManager
) : ComponentRegistryService {

private val jiraComponentVersionFormatter = createJiraComponentVersionFormatter(client)
private lateinit var versionNames: VersionNames

private val jiraComponentVersionFormatter = createJiraComponentVersionFormatter()

private var fixedRemoteDate: Date = Date(0L)

Expand Down Expand Up @@ -174,25 +193,28 @@ class ComponentRegistryServiceImpl @Inject constructor(
.toModel()
}

private fun createJiraComponentVersionFormatter(client: ComponentsRegistryServiceClient): JiraComponentVersionFormatter {
val versionNamesMap = client.getVersionNames()
val versionNames = VersionNames(
versionNamesMap["service-branch"]
?: throw IllegalArgumentException("service-branch version name must be defined"),
versionNamesMap["service"] ?: throw IllegalArgumentException("service version name must be defined"),
versionNamesMap["minor"] ?: throw IllegalArgumentException("minor version name must be defined")
)
return JiraComponentVersionFormatter(versionNames)
private fun createJiraComponentVersionFormatter(): JiraComponentVersionFormatter {
return JiraComponentVersionFormatter(getVersionNames())
}

override fun getAllComponents(): List<Component> {
return allComponentsCache.get(Unit)!!
}

override fun getVersionNames(): VersionNames {
if (::versionNames.isInitialized) {
return versionNames
}
val vn = client.getVersionNames()
return vn.toModel()
}

override fun getComponent(component: String): Optional<Component> {
return componentsCache.get(component)!!
}

override fun getComponentVersionFormatter() = jiraComponentVersionFormatter

override fun isVersionMinor(version: Version): Boolean {
return isMinorVersionCache.get(version)!!
}
Expand Down Expand Up @@ -311,6 +333,10 @@ class ComponentRegistryServiceImpl @Inject constructor(
)
}

private fun VersionNamesDTO.toModel(): VersionNames {
return VersionNames(serviceBranch, service, minor)
}

private fun VcsRootDateDTO.toModel(): VcsRootLastChangeDate {
return VcsRootLastChangeDate(root.toModel(), date)
}
Expand Down

0 comments on commit e2676bb

Please sign in to comment.