Skip to content

Commit dd51572

Browse files
committed
Remove old config cleanup
These should be long gone. The old config would not affect the plugin going forward anyway because the syntax is going to change to support multiple deployment.
1 parent 8269468 commit dd51572

File tree

2 files changed

+0
-83
lines changed

2 files changed

+0
-83
lines changed

src/sshConfig.test.ts

-70
Original file line numberDiff line numberDiff line change
@@ -138,76 +138,6 @@ Host *
138138
})
139139
})
140140

141-
it("removes old coder SSH config and adds the new one", async () => {
142-
const existentSSHConfig = `Host coder-vscode--*
143-
ConnectTimeout=0
144-
HostName coder.something
145-
LogLevel ERROR
146-
ProxyCommand command
147-
StrictHostKeyChecking=no
148-
UserKnownHostsFile=/dev/null`
149-
mockFileSystem.readFile.mockResolvedValueOnce(existentSSHConfig)
150-
151-
const sshConfig = new SSHConfig(sshFilePath, mockFileSystem)
152-
await sshConfig.load()
153-
await sshConfig.update({
154-
Host: "coder-vscode--*",
155-
ProxyCommand: "some-command-here",
156-
ConnectTimeout: "0",
157-
StrictHostKeyChecking: "no",
158-
UserKnownHostsFile: "/dev/null",
159-
LogLevel: "ERROR",
160-
})
161-
162-
const expectedOutput = `# --- START CODER VSCODE ---
163-
Host coder-vscode--*
164-
ConnectTimeout 0
165-
LogLevel ERROR
166-
ProxyCommand some-command-here
167-
StrictHostKeyChecking no
168-
UserKnownHostsFile /dev/null
169-
# --- END CODER VSCODE ---`
170-
171-
expect(mockFileSystem.writeFile).toBeCalledWith(sshFilePath, expectedOutput, {
172-
encoding: "utf-8",
173-
mode: 384,
174-
})
175-
})
176-
177-
it("it does not remove a user-added block that only matches the host of an old coder SSH config", async () => {
178-
const existentSSHConfig = `Host coder-vscode--*
179-
ForwardAgent=yes`
180-
mockFileSystem.readFile.mockResolvedValueOnce(existentSSHConfig)
181-
182-
const sshConfig = new SSHConfig(sshFilePath, mockFileSystem)
183-
await sshConfig.load()
184-
await sshConfig.update({
185-
Host: "coder-vscode--*",
186-
ProxyCommand: "some-command-here",
187-
ConnectTimeout: "0",
188-
StrictHostKeyChecking: "no",
189-
UserKnownHostsFile: "/dev/null",
190-
LogLevel: "ERROR",
191-
})
192-
193-
const expectedOutput = `Host coder-vscode--*
194-
ForwardAgent=yes
195-
196-
# --- START CODER VSCODE ---
197-
Host coder-vscode--*
198-
ConnectTimeout 0
199-
LogLevel ERROR
200-
ProxyCommand some-command-here
201-
StrictHostKeyChecking no
202-
UserKnownHostsFile /dev/null
203-
# --- END CODER VSCODE ---`
204-
205-
expect(mockFileSystem.writeFile).toBeCalledWith(sshFilePath, expectedOutput, {
206-
encoding: "utf-8",
207-
mode: 384,
208-
})
209-
})
210-
211141
it("override values", async () => {
212142
mockFileSystem.readFile.mockRejectedValueOnce("No file found")
213143
const sshConfig = new SSHConfig(sshFilePath, mockFileSystem)

src/sshConfig.ts

-13
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,6 @@ export class SSHConfig {
103103
}
104104

105105
async update(values: SSHValues, overrides: Record<string, string> = defaultSSHConfigResponse) {
106-
// We should remove this in March 2023 because there is not going to have
107-
// old configs
108-
this.cleanUpOldConfig()
109106
const block = this.getBlock()
110107
const newBlock = this.buildBlock(values, overrides)
111108
if (block) {
@@ -116,16 +113,6 @@ export class SSHConfig {
116113
await this.save()
117114
}
118115

119-
private async cleanUpOldConfig() {
120-
const raw = this.getRaw()
121-
const oldConfig = raw.split("\n\n").find((config) => config.startsWith("Host coder-vscode--*"))
122-
// Perform additional sanity check that the block also contains a
123-
// ProxyCommand, otherwise it might be a different block.
124-
if (oldConfig && oldConfig.includes(" ProxyCommand ")) {
125-
this.raw = raw.replace(oldConfig, "")
126-
}
127-
}
128-
129116
private getBlock(): Block | undefined {
130117
const raw = this.getRaw()
131118
const startBlockIndex = raw.indexOf(this.startBlockComment)

0 commit comments

Comments
 (0)