Disable kubectl download mirror options when not available (#3956)

This commit is contained in:
Sebastian Malton authored and GitHub committed 2021-10-19 09:22:06 -04:00
1 parent 125a073007
commit cbffb85650
3 files changed
+32 -17

No files matched your search

+22 -2
View File
@@ -136,12 +136,32 @@ const allowErrorReporting: PreferenceDescription<boolean> = {
},
};
export interface DownloadMirror {
url: string;
label: string;
platforms: Set<NodeJS.Platform>;
}
export const defaultPackageMirror = "default";
export const packageMirrors = new Map<string, DownloadMirror>([
[defaultPackageMirror, {
url: "https://storage.googleapis.com/kubernetes-release/release",
label: "Default (Google)",
platforms: new Set(["darwin", "win32", "linux"]),
}],
["china", {
url: "https://mirror.azure.cn/kubernetes/kubectl",
label: "China (Azure)",
platforms: new Set(["win32", "linux"]),
}],
]);
const downloadMirror: PreferenceDescription<string> = {
fromStore(val) {
return val ?? "default";
return packageMirrors.has(val) ? val : defaultPackageMirror;
},
toStore(val) {
if (!val || val === "default") {
if (!val || val === defaultPackageMirror) {
return undefined;
}