verify-remote-ssh-target.mjs 869 B

12345678910111213141516171819202122
  1. const SUPPORTED_ARCHITECTURES = new Set(["x64", "arm64"]);
  2. export function resolveVerificationTarget(explicitTarget, architecture = process.arch) {
  3. if (explicitTarget !== undefined) {
  4. if (!/^linux-(?:x64|arm64)$/.test(explicitTarget)) {
  5. throw new Error(
  6. `Invalid --target: ${explicitTarget}; verify-remote-ssh only accepts Linux targets`,
  7. );
  8. }
  9. return explicitTarget;
  10. }
  11. if (!SUPPORTED_ARCHITECTURES.has(architecture)) {
  12. throw new Error(`Unsupported host architecture for verify-remote-ssh: ${architecture}`);
  13. }
  14. return `linux-${architecture}`;
  15. }
  16. export function dockerPlatformForTarget(target) {
  17. const architecture = target === "linux-x64" ? "amd64" : target === "linux-arm64" ? "arm64" : null;
  18. if (!architecture) throw new Error(`Unsupported Linux verification target: ${target}`);
  19. return `linux/${architecture}`;
  20. }