-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fcba274
commit 2970c67
Showing
12 changed files
with
137 additions
and
75 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
components/ide/jetbrains/toolbox/src/main/kotlin/io/gitpod/toolbox/gateway/GitpodSettings.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Copyright (c) 2024 Gitpod GmbH. All rights reserved. | ||
// Licensed under the GNU Affero General Public License (AGPL). | ||
// See License.AGPL.txt in the project root for license information. | ||
|
||
package io.gitpod.toolbox.gateway | ||
|
||
import io.gitpod.toolbox.service.Utils | ||
import org.slf4j.LoggerFactory | ||
|
||
class GitpodSettings { | ||
private val logger = LoggerFactory.getLogger(javaClass) | ||
private val settingsChangedListeners: MutableList<(String, String) -> Unit> = mutableListOf() | ||
|
||
private fun getStoreKey(key: SettingKey) = "GITPOD_SETTINGS:${key.name}" | ||
|
||
private fun updateSetting(key: SettingKey, value: String) { | ||
logger.debug("updateSetting ${key.name}=$value") | ||
Utils.settingStore[getStoreKey(key)] = value | ||
settingsChangedListeners.forEach { it(key.name, value) } | ||
} | ||
|
||
fun onSettingsChanged(listener: (String, String) -> Unit) { | ||
settingsChangedListeners.add(listener) | ||
} | ||
|
||
var organizationId: String? | ||
get() { | ||
val value = Utils.settingStore[getStoreKey(SettingKey.ORGANIZATION_ID)] | ||
return if (value.isNullOrBlank()) null else value | ||
} | ||
set(value) { | ||
updateSetting(SettingKey.ORGANIZATION_ID, value ?: "") | ||
} | ||
|
||
fun resetSettings(host: String = "gitpod.io") { | ||
logger.info("=============reset for $host") | ||
gitpodHost = host | ||
organizationId = "" | ||
} | ||
|
||
var gitpodHost: String | ||
get() = Utils.settingStore[getStoreKey(SettingKey.GITPOD_HOST)] ?: "gitpod.io" | ||
set(value) { | ||
updateSetting(SettingKey.GITPOD_HOST, value) | ||
} | ||
|
||
enum class SettingKey { | ||
ORGANIZATION_ID, | ||
GITPOD_HOST | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.