From f616d16c338b744d5d1c252fd08733955caf2090 Mon Sep 17 00:00:00 2001 From: Inaki Villar Date: Thu, 13 Jun 2024 10:30:25 -0700 Subject: [PATCH] Added getMaybeBooleanInput to parse boolean inputs --- sources/src/configuration.ts | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/sources/src/configuration.ts b/sources/src/configuration.ts index 378f0ea..4621cf3 100644 --- a/sources/src/configuration.ts +++ b/sources/src/configuration.ts @@ -216,24 +216,24 @@ export class BuildScanConfig { return core.getInput('develocity-token-expiry') } - getDevelocityInjectionEnabled(): string { - return core.getInput('develocity-injection-enabled') + getDevelocityInjectionEnabled(): boolean | undefined { + return getMaybeBooleanInput('develocity-injection-enabled') } getDevelocityUrl(): string { return core.getInput('develocity-url') } - getDevelocityAllowUntrustedServer(): string { - return core.getInput('develocity-allow-untrusted-server') + getDevelocityAllowUntrustedServer(): boolean | undefined { + return getMaybeBooleanInput('develocity-allow-untrusted-server') } - getDevelocityCaptureFileFingerprints(): string { - return core.getInput('develocity-capture-file-fingerprints') + getDevelocityCaptureFileFingerprints(): boolean | undefined { + return getMaybeBooleanInput('develocity-capture-file-fingerprints') } - getDevelocityEnforceUrl(): string { - return core.getInput('develocity-enforce-url') + getDevelocityEnforceUrl(): boolean | undefined { + return getMaybeBooleanInput('develocity-enforce-url') } getDevelocityPluginVersion(): string { @@ -369,3 +369,15 @@ function getBooleanInput(paramName: string, paramDefault = false): boolean { } throw TypeError(`The value '${paramValue} is not valid for '${paramName}. Valid values are: [true, false]`) } + +function getMaybeBooleanInput(paramName: string): boolean | undefined { + const paramValue = core.getInput(paramName) + switch (paramValue?.toLowerCase().trim()) { + case 'false': + return false + case 'true': + return true + default: + return undefined + } +}