-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Merge pull request #39 from docker/cm/remove-credcheck"
- Loading branch information
1 parent
fa32df8
commit d7d309c
Showing
4 changed files
with
72 additions
and
4 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { spawnSync } from "child_process"; | ||
import { env } from "vscode"; | ||
|
||
export const getCredential = async (service: string) => { | ||
const auth = spawnSync( | ||
`echo "https://index.docker.io/v1/" | docker-credential-desktop get`, | ||
{ | ||
shell: process.platform === 'win32' ? "powershell" : true, | ||
} | ||
); | ||
let Username = `vscode-${env.machineId}`; | ||
let Password = ""; | ||
if (auth.stdout.toString().startsWith("{") && auth.status === 0 && !auth.error) { | ||
try { | ||
const authPayload = JSON.parse(auth.stdout.toString()) as { | ||
"ServerURL": string, | ||
"Username": string, | ||
"Secret": string | ||
}; | ||
Username = authPayload.Username; | ||
Password = authPayload.Secret; | ||
} | ||
catch (e) { | ||
throw new Error(`Expected JSON from docker-credential-desktop, got STDOUT: ${auth.stdout.toString()} STDERR: ${auth.stderr.toString()} ERR: ${(auth.error || "N/A").toString()}`); | ||
} | ||
} | ||
return { | ||
Username, | ||
Password | ||
}; | ||
}; |
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