(record: Record<string, unknown>)
| 216 | } |
| 217 | |
| 218 | function parseGitHubActionsArtifactSource(record: Record<string, unknown>): DaemonInstallSource { |
| 219 | const owner = readRequiredGitHubArtifactText(record, 'owner'); |
| 220 | const repo = readRequiredGitHubArtifactText(record, 'repo'); |
| 221 | const hasArtifactId = record.artifactId !== undefined; |
| 222 | const hasRunId = record.runId !== undefined; |
| 223 | const hasArtifactName = record.artifactName !== undefined; |
| 224 | if (hasArtifactId && (hasRunId || hasArtifactName)) { |
| 225 | throw new AppError( |
| 226 | 'INVALID_ARGS', |
| 227 | 'Invalid params: source must specify either artifactId or artifactName, not both', |
| 228 | ); |
| 229 | } |
| 230 | if (!hasArtifactId && hasRunId && !hasArtifactName) { |
| 231 | throw new AppError( |
| 232 | 'INVALID_ARGS', |
| 233 | 'Invalid params: source.artifactName is required when source.runId is specified', |
| 234 | ); |
| 235 | } |
| 236 | if (!hasArtifactId && !hasArtifactName) { |
| 237 | throw new AppError( |
| 238 | 'INVALID_ARGS', |
| 239 | 'Invalid params: source must specify artifactId or artifactName', |
| 240 | ); |
| 241 | } |
| 242 | if (hasArtifactId) { |
| 243 | return { |
| 244 | kind: 'github-actions-artifact', |
| 245 | owner, |
| 246 | repo, |
| 247 | artifactId: readGitHubArtifactInteger(record, 'artifactId'), |
| 248 | }; |
| 249 | } |
| 250 | let runId: number | undefined; |
| 251 | if (hasRunId) { |
| 252 | runId = readGitHubArtifactInteger(record, 'runId'); |
| 253 | } |
| 254 | return { |
| 255 | kind: 'github-actions-artifact', |
| 256 | owner, |
| 257 | repo, |
| 258 | ...(hasRunId ? { runId } : {}), |
| 259 | artifactName: readRequiredGitHubArtifactText(record, 'artifactName'), |
| 260 | }; |
| 261 | } |
| 262 | |
| 263 | function toLeaseDaemonRequest( |
| 264 | command: 'lease_allocate' | 'lease_heartbeat' | 'lease_release', |
no test coverage detected