Skip to content

Commit aa930a4

Browse files
committed
fix: read only settings acted as snapshots
- they did not reflect any subsequent update because updates create a new backing readonly instance - with this patch we simplified the code even more by exposing a readonly interface with all of the implementation in the CoderSettingsStore. PluginSettingsStore and Environments are the only persist-able stores. - because read only instances share the same settings store instances any update on the writable will reflect on the readable instances as well.
1 parent 09e15db commit aa930a4

File tree

6 files changed

+338
-299
lines changed

6 files changed

+338
-299
lines changed

src/main/kotlin/com/coder/toolbox/cli/CoderCLIManager.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import com.coder.toolbox.cli.ex.ResponseException
66
import com.coder.toolbox.cli.ex.SSHConfigFormatException
77
import com.coder.toolbox.sdk.v2.models.Workspace
88
import com.coder.toolbox.sdk.v2.models.WorkspaceAgent
9-
import com.coder.toolbox.settings.CoderSettings
9+
import com.coder.toolbox.settings.ReadOnlyCoderSettings
1010
import com.coder.toolbox.util.CoderHostnameVerifier
1111
import com.coder.toolbox.util.InvalidVersionException
1212
import com.coder.toolbox.util.OS
@@ -125,7 +125,7 @@ class CoderCLIManager(
125125
private val deploymentURL: URL,
126126
private val logger: Logger,
127127
// Plugin configuration.
128-
private val settings: CoderSettings,
128+
private val settings: ReadOnlyCoderSettings,
129129
// If the binary directory is not writable, this can be used to force the
130130
// manager to download to the data directory instead.
131131
forceDownloadToData: Boolean = false,
@@ -267,21 +267,21 @@ class CoderCLIManager(
267267
"--url",
268268
escape(deploymentURL.toString()),
269269
if (!settings.headerCommand.isNullOrBlank()) "--header-command" else null,
270-
if (!settings.headerCommand.isNullOrBlank()) escapeSubcommand(settings.headerCommand) else null,
270+
if (!settings.headerCommand.isNullOrBlank()) escapeSubcommand(settings.headerCommand!!) else null,
271271
"ssh",
272272
"--stdio",
273273
if (settings.disableAutostart && feats.disableAutostart) "--disable-autostart" else null,
274274
)
275275
val proxyArgs = baseArgs + listOfNotNull(
276276
if (!settings.sshLogDirectory.isNullOrBlank()) "--log-dir" else null,
277-
if (!settings.sshLogDirectory.isNullOrBlank()) escape(settings.sshLogDirectory) else null,
277+
if (!settings.sshLogDirectory.isNullOrBlank()) escape(settings.sshLogDirectory!!) else null,
278278
if (feats.reportWorkspaceUsage) "--usage-app=jetbrains" else null,
279279
)
280280
val backgroundProxyArgs =
281281
baseArgs + listOfNotNull(if (feats.reportWorkspaceUsage) "--usage-app=disable" else null)
282282
val extraConfig =
283283
if (!settings.sshConfigOptions.isNullOrBlank()) {
284-
"\n" + settings.sshConfigOptions.prependIndent(" ")
284+
"\n" + settings.sshConfigOptions!!.prependIndent(" ")
285285
} else {
286286
""
287287
}

src/main/kotlin/com/coder/toolbox/settings/CoderSettings.kt

Lines changed: 0 additions & 244 deletions
This file was deleted.

0 commit comments

Comments
 (0)