Skip to content

Impl: test minimum supported Coder version #118

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Dec 9, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
impl: check if Coder version is in range
- compare if version is in between min&max supported
  versions of Coder
  • Loading branch information
fioan89 committed Dec 9, 2022
commit 91ce5514e317a3290f4c7024e0ce06cffefd9b3c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import org.jetbrains.annotations.PropertyKey
private const val BUNDLE = "version.CoderSupportedVersions"

object CoderSupportedVersions : DynamicBundle(BUNDLE) {
val minCompatibleCoderVersion = CoderSemVer.parse(message("minCompatibleCoderVersion"))
val maxCompatibleCoderVersion = CoderSemVer.parse(message("maxCompatibleCoderVersion"))

@JvmStatic
Expand Down
1 change: 1 addition & 0 deletions src/main/kotlin/com/coder/gateway/sdk/CoderSemVer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class CoderSemVer(private val major: Long = 0, private val minor: Long = 0, priv
require(patch >= 0) { "Coder minor version must be a positive number" }
}

fun isInClosedRange(start: CoderSemVer, endInclusive: CoderSemVer) = this in start..endInclusive
fun isCompatibleWith(other: CoderSemVer): Boolean {
// in the initial development phase minor changes when there are API incompatibilities
if (this.major == 0L) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,7 @@ class CoderWorkspacesStepView(val enableNextButtonCallback: (Boolean) -> Unit) :
}
} else {
val coderVersion = CoderSemVer.parse(coderClient.buildVersion)
val testedCoderVersion = CoderSupportedVersions.maxCompatibleCoderVersion

if (!testedCoderVersion.isCompatibleWith(coderVersion)) {
if (!coderVersion.isInClosedRange(CoderSupportedVersions.minCompatibleCoderVersion, CoderSupportedVersions.maxCompatibleCoderVersion)) {
notificationBanner.apply {
component.isVisible = true
showWarning(CoderGatewayBundle.message("gateway.connector.view.coder.workspaces.unsupported.coder.version", coderClient.buildVersion))
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
minCompatibleCoderVersion=0.12.9
maxCompatibleCoderVersion=0.13.1