format with more modern prettier

Signed-off-by: Lee Briggs <lee@leebriggs.co.uk>
This commit is contained in:
Lee Briggs 2026-04-26 20:29:45 -07:00
parent 78ee815094
commit 5e5be6a255
No known key found for this signature in database
GPG key ID: A4D09B96FDFEB505
2 changed files with 45 additions and 45 deletions

View file

@ -49,7 +49,7 @@ async function logout(): Promise<void> {
// Don't fail the action if logout fails - it's just cleanup
core.warning(`Failed to logout from Tailscale: ${error}`);
core.info(
"Your ephemeral node will eventually be cleaned up by Tailscale"
"Your ephemeral node will eventually be cleaned up by Tailscale",
);
}
} catch (error) {

View file

@ -92,7 +92,7 @@ async function run(): Promise<void> {
config.useCache
) {
throw new Error(
"Caching of unstable releases is not supported on macOS runners"
"Caching of unstable releases is not supported on macOS runners",
);
}
@ -136,7 +136,7 @@ async function run(): Promise<void> {
core.warning(`Failed to get Tailscale status: ${err}`);
if (runnerOS === runnerMacOS) {
core.setFailed(
`❌ Tailscale status is required in order to configure macOS`
`❌ Tailscale status is required in order to configure macOS`,
);
process.exit(2);
}
@ -158,8 +158,8 @@ async function pingHostsIfNecessary(config: TailscaleConfig): Promise<void> {
core.info(
`Will ping hosts ${config.pingHosts.join(
","
)} up to 3 minutes each (in parallel) in order to check connectivity`
",",
)} up to 3 minutes each (in parallel) in order to check connectivity`,
);
let pings = config.pingHosts.map((host) => pingHost(host));
for (const ping of pings) {
@ -243,7 +243,7 @@ async function getInputs(): Promise<TailscaleConfig> {
if (config.oauthSecret && !config.tags) {
throw new Error(
"the tags parameter is required when using an OAuth client"
"the tags parameter is required when using an OAuth client",
);
}
@ -257,7 +257,7 @@ function validateAuth(config: TailscaleConfig): void {
(!config.audience || !config.oauthClientId || !config.tags)
) {
throw new Error(
"Please provide either an auth key, OAuth secret and tags, or federated identity client ID and audience with tags."
"Please provide either an auth key, OAuth secret and tags, or federated identity client ID and audience with tags.",
);
}
@ -267,14 +267,14 @@ function validateAuth(config: TailscaleConfig): void {
semver.gt("1.90.0", config.version)
) {
throw new Error(
"Workload identity federation requires using tailscale version 1.90.0 or later."
"Workload identity federation requires using tailscale version 1.90.0 or later.",
);
}
}
async function resolveVersion(
version: string,
runnerOS: string
runnerOS: string,
): Promise<string> {
if (runnerOS === runnerMacOS && version === versionUnstable) {
return "main";
@ -342,7 +342,7 @@ function getTailscaleArch(runnerOS: string): string {
async function installTailscale(
config: TailscaleConfig,
runnerOS: string
runnerOS: string,
): Promise<installMethod> {
const cacheKey = generateCacheKey(config, runnerOS);
const toolPath = getToolPath(config, runnerOS);
@ -352,7 +352,7 @@ async function installTailscale(
const cacheHit = await cache.restoreCache([toolPath], cacheKey);
if (cacheHit) {
core.info(
`Found Tailscale ${config.resolvedVersion} in cache: ${toolPath}`
`Found Tailscale ${config.resolvedVersion} in cache: ${toolPath}`,
);
// For Windows, install the cached MSI
@ -409,7 +409,7 @@ async function calculateFileSha256(filePath: string): Promise<string> {
async function installTailscaleLinux(
config: TailscaleConfig,
toolPath: string
toolPath: string,
): Promise<void> {
// Determine if stable or unstable
const minor = parseInt(config.resolvedVersion.split(".")[1]);
@ -452,18 +452,18 @@ async function installTailscaleLinux(
const extractedPath = await tc.extractTar(tarPath, undefined, "xz");
const extractedDir = path.join(
extractedPath,
`tailscale_${config.resolvedVersion}_${config.arch}`
`tailscale_${config.resolvedVersion}_${config.arch}`,
);
// Create tool directory and copy binaries there for caching
fs.mkdirSync(toolPath, { recursive: true });
fs.copyFileSync(
path.join(extractedDir, cmdTailscale),
path.join(toolPath, cmdTailscale)
path.join(toolPath, cmdTailscale),
);
fs.copyFileSync(
path.join(extractedDir, cmdTailscaled),
path.join(toolPath, cmdTailscaled)
path.join(toolPath, cmdTailscaled),
);
// Install binaries to /usr/local/bin
@ -490,7 +490,7 @@ async function installTailscaleLinux(
async function installTailscaleWindows(
config: TailscaleConfig,
toolPath: string,
fromCache: boolean = false
fromCache: boolean = false,
): Promise<void> {
// Create tool directory
fs.mkdirSync(toolPath, { recursive: true });
@ -576,11 +576,11 @@ async function installTailscaleWindows(
async function installTailscaleMacOS(
config: TailscaleConfig,
toolPath: string
toolPath: string,
): Promise<installMethod> {
if (!(await isHomebrewAvailable())) {
core.notice(
"Homebrew not found on macOS runner; installing Tailscale from source."
"Homebrew not found on macOS runner; installing Tailscale from source.",
);
await installTailscaleFromSourceOnMacOS(config, toolPath);
return "source";
@ -599,7 +599,7 @@ async function installTailscaleMacOS(
}
core.notice(
`Homebrew tailscale formula version ${formulaVersion} does not match requested version ${config.resolvedVersion}; installing Tailscale from source.`
`Homebrew tailscale formula version ${formulaVersion} does not match requested version ${config.resolvedVersion}; installing Tailscale from source.`,
);
await installTailscaleFromSourceOnMacOS(config, toolPath);
return "source";
@ -629,18 +629,18 @@ async function getHomebrewTailscaleFormulaVersion(): Promise<
{
silent: true,
ignoreReturnCode: true,
}
},
);
} catch (error) {
core.notice(
`Unable to inspect Homebrew tailscale formula metadata: ${error}; installing Tailscale from source.`
`Unable to inspect Homebrew tailscale formula metadata: ${error}; installing Tailscale from source.`,
);
return undefined;
}
if (out.exitCode !== 0) {
core.notice(
"Unable to inspect Homebrew tailscale formula; installing Tailscale from source."
"Unable to inspect Homebrew tailscale formula; installing Tailscale from source.",
);
return undefined;
}
@ -650,14 +650,14 @@ async function getHomebrewTailscaleFormulaVersion(): Promise<
return info?.formulae?.[0]?.versions?.stable;
} catch (error) {
core.notice(
`Unable to parse Homebrew tailscale formula metadata: ${error}; installing Tailscale from source.`
`Unable to parse Homebrew tailscale formula metadata: ${error}; installing Tailscale from source.`,
);
return undefined;
}
}
async function installTailscaleWithHomebrew(
resolvedVersion: string
resolvedVersion: string,
): Promise<void> {
await execSilent("install tailscale via homebrew", "brew", [
"install",
@ -670,7 +670,7 @@ async function installTailscaleWithHomebrew(
core.info(
`Installed Homebrew tailscale version ${
installedVersion || "unknown"
} does not match requested version ${resolvedVersion}; attempting upgrade.`
} does not match requested version ${resolvedVersion}; attempting upgrade.`,
);
await execSilent("upgrade tailscale via homebrew", "brew", [
"upgrade",
@ -684,7 +684,7 @@ async function installTailscaleWithHomebrew(
throw new Error(
`Homebrew installed tailscale version ${
installedVersion || "unknown"
}, expected ${resolvedVersion}`
}, expected ${resolvedVersion}`,
);
}
}
@ -700,11 +700,11 @@ async function getHomebrewInstalledTailscaleVersion(): Promise<
{
silent: true,
ignoreReturnCode: true,
}
},
);
} catch (error) {
core.debug(
`Unable to inspect installed Homebrew tailscale version: ${error}`
`Unable to inspect installed Homebrew tailscale version: ${error}`,
);
return undefined;
}
@ -718,7 +718,7 @@ async function getHomebrewInstalledTailscaleVersion(): Promise<
return info?.formulae?.[0]?.installed?.[0]?.version;
} catch (error) {
core.debug(
`Unable to parse installed Homebrew tailscale version: ${error}`
`Unable to parse installed Homebrew tailscale version: ${error}`,
);
return undefined;
}
@ -726,14 +726,14 @@ async function getHomebrewInstalledTailscaleVersion(): Promise<
async function installTailscaleFromSourceOnMacOS(
config: TailscaleConfig,
toolPath: string
toolPath: string,
): Promise<void> {
core.info("Building tailscale from src on macOS...");
// Clone the repo
await execSilent(
"clone tailscale repo",
"git clone https://github.com/tailscale/tailscale.git tailscale"
"git clone https://github.com/tailscale/tailscale.git tailscale",
);
// Checkout the resolved version
@ -743,7 +743,7 @@ async function installTailscaleFromSourceOnMacOS(
[],
{
cwd: cmdTailscale,
}
},
);
// Create tool directory and copy binaries there for caching
@ -761,7 +761,7 @@ async function installTailscaleFromSourceOnMacOS(
...process.env,
TS_USE_TOOLCHAIN: "1",
},
}
},
);
}
@ -790,7 +790,7 @@ async function installTailscaleFromSourceOnMacOS(
async function startTailscaleDaemon(
config: TailscaleConfig,
installedWith: installMethod
installedWith: installMethod,
): Promise<void> {
if (installedWith === "brew") {
core.info("Starting Homebrew-installed tailscaled daemon manually...");
@ -854,7 +854,7 @@ async function waitForDaemonReady(): Promise<void> {
// If we get any valid response from the API, the daemon is ready
if (status) {
core.info(
`Daemon ready! Initial state: ${status.BackendState || "Unknown"}`
`Daemon ready! Initial state: ${status.BackendState || "Unknown"}`,
);
return;
}
@ -868,13 +868,13 @@ async function waitForDaemonReady(): Promise<void> {
}
throw new Error(
`tailscaled daemon did not become ready within timeout, last error: ${lastErr}`
`tailscaled daemon did not become ready within timeout, last error: ${lastErr}`,
);
}
async function connectToTailscale(
config: TailscaleConfig,
runnerOS: string
runnerOS: string,
): Promise<void> {
// Determine hostname
let hostname = config.hostname;
@ -950,13 +950,13 @@ async function connectToTailscale(
await Promise.race([
execSilent("tailscale up", execArgs[0], execArgs.slice(1)),
new Promise<never>((_, reject) =>
setTimeout(() => reject(new Error("Timeout")), timeoutMs)
setTimeout(() => reject(new Error("Timeout")), timeoutMs),
),
]);
// Success
core.info(
`✅ Tailscale up command completed successfully on attempt ${attempt}`
`✅ Tailscale up command completed successfully on attempt ${attempt}`,
);
return;
} catch (error) {
@ -997,7 +997,7 @@ function sleep(ms: number): Promise<void> {
function generateCacheKey(
config: TailscaleConfig,
runnerOS: string
runnerOS: string,
): string | undefined {
if (!config.useCache) {
return undefined;
@ -1016,13 +1016,13 @@ function getToolPath(config: TailscaleConfig, runnerOS: string): string {
cacheDirectory,
cmdTailscale,
config.resolvedVersion,
`${runnerOS}-${config.arch}`
`${runnerOS}-${config.arch}`,
);
}
async function installCachedBinaries(
toolPath: string,
runnerOS: string
runnerOS: string,
): Promise<void> {
if (runnerOS === runnerLinux || runnerOS === runnerMacOS) {
// Copy cached binaries to /usr/local/bin
@ -1063,7 +1063,7 @@ async function configureDNSOnMacOS(status: tailscaleStatus): Promise<void> {
}
core.info(
`Setting system DNS server to 100.100.100.100 and searchdomains to ${status.CurrentTailnet.MagicDNSSuffix}`
`Setting system DNS server to 100.100.100.100 and searchdomains to ${status.CurrentTailnet.MagicDNSSuffix}`,
);
try {
await execSilent("set dns servers", "networksetup", [
@ -1100,7 +1100,7 @@ async function execSilent(
label: string,
cmd: string,
args?: string[],
opts?: {}
opts?: {},
): Promise<exec.ExecOutput> {
core.info(`▶️ ${label}`);
const out = await exec.getExecOutput(cmd, args, {
@ -1116,7 +1116,7 @@ async function execSilent(
throw new execError(
`${cmd} failed with exit code ${out.exitCode}`,
out.exitCode,
out.stderr
out.stderr,
);
}
return out;