Skip to content

Commit 67439f3

Browse files
committed
use global dag client
1 parent 8813c1a commit 67439f3

File tree

527 files changed

+23210
-3711
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

527 files changed

+23210
-3711
lines changed

ansible-lint/sdk/client.gen.ts

+414-97
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { log } from "../utils.ts";
2+
import { ErrorCodes, ErrorNames } from "./errors-codes.ts";
3+
4+
export interface DaggerSDKErrorOptions {
5+
cause?: Error;
6+
}
7+
8+
/**
9+
* The base error. Every other error inherits this error.
10+
*/
11+
export abstract class DaggerSDKError extends Error {
12+
/**
13+
* The name of the dagger error.
14+
*/
15+
abstract readonly name: ErrorNames;
16+
17+
/**
18+
* The dagger specific error code.
19+
* Use this to identify dagger errors programmatically.
20+
*/
21+
abstract readonly code: ErrorCodes;
22+
23+
/**
24+
* The original error, which caused the DaggerSDKError.
25+
*/
26+
cause?: Error;
27+
28+
protected constructor(message: string, options?: DaggerSDKErrorOptions) {
29+
super(message);
30+
this.cause = options?.cause;
31+
}
32+
33+
/**
34+
* @hidden
35+
*/
36+
get [Symbol.toStringTag]() {
37+
return this.name;
38+
}
39+
40+
/**
41+
* Pretty prints the error
42+
*/
43+
printStackTrace() {
44+
log(this.stack);
45+
}
46+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { DaggerSDKError, DaggerSDKErrorOptions } from "./DaggerSDKError.ts"
2+
import { ERROR_CODES, ERROR_NAMES } from "./errors-codes.ts"
3+
4+
interface DockerImageRefValidationErrorOptions extends DaggerSDKErrorOptions {
5+
ref: string
6+
}
7+
8+
/**
9+
* This error is thrown if the passed image reference does not pass validation and is not compliant with the
10+
* DockerImage constructor.
11+
*/
12+
export class DockerImageRefValidationError extends DaggerSDKError {
13+
name = ERROR_NAMES.DockerImageRefValidationError
14+
code = ERROR_CODES.DockerImageRefValidationError
15+
16+
/**
17+
* The docker image reference, which caused the error.
18+
*/
19+
ref: string
20+
21+
/**
22+
* @hidden
23+
*/
24+
constructor(message: string, options: DockerImageRefValidationErrorOptions) {
25+
super(message, options)
26+
this.ref = options?.ref
27+
}
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { DaggerSDKError, DaggerSDKErrorOptions } from "./DaggerSDKError.ts";
2+
import { ERROR_CODES, ERROR_NAMES } from "./errors-codes.ts";
3+
4+
interface EngineSessionConnectParamsParseErrorOptions
5+
extends DaggerSDKErrorOptions {
6+
parsedLine: string;
7+
}
8+
9+
/**
10+
* This error is thrown if the EngineSession does not manage to parse the required connection parameters from the session binary
11+
*/
12+
export class EngineSessionConnectParamsParseError extends DaggerSDKError {
13+
name = ERROR_NAMES.EngineSessionConnectParamsParseError;
14+
code = ERROR_CODES.EngineSessionConnectParamsParseError;
15+
16+
/**
17+
* the line, which caused the error during parsing, if the error was caused because of parsing.
18+
*/
19+
parsedLine: string;
20+
21+
/**
22+
* @hidden
23+
*/
24+
constructor(
25+
message: string,
26+
options: EngineSessionConnectParamsParseErrorOptions
27+
) {
28+
super(message, options);
29+
this.parsedLine = options.parsedLine;
30+
}
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { DaggerSDKError, DaggerSDKErrorOptions } from "./DaggerSDKError.ts";
2+
import { ERROR_CODES, ERROR_NAMES } from "./errors-codes.ts";
3+
4+
interface EngineSessionConnectionTimeoutErrorOptions
5+
extends DaggerSDKErrorOptions {
6+
timeOutDuration: number;
7+
}
8+
9+
/**
10+
* This error is thrown if the EngineSession does not manage to parse the required port successfully because the sessions connection timed out.
11+
*/
12+
export class EngineSessionConnectionTimeoutError extends DaggerSDKError {
13+
name = ERROR_NAMES.EngineSessionConnectionTimeoutError;
14+
code = ERROR_CODES.EngineSessionConnectionTimeoutError;
15+
16+
/**
17+
* The duration until the timeout occurred in ms.
18+
*/
19+
timeOutDuration: number;
20+
21+
/**
22+
* @hidden
23+
*/
24+
constructor(
25+
message: string,
26+
options: EngineSessionConnectionTimeoutErrorOptions
27+
) {
28+
super(message, options);
29+
this.timeOutDuration = options.timeOutDuration;
30+
}
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { DaggerSDKError, DaggerSDKErrorOptions } from "./DaggerSDKError.ts";
2+
import { ERROR_CODES, ERROR_NAMES } from "./errors-codes.ts";
3+
4+
type EngineSessionErrorOptions = DaggerSDKErrorOptions;
5+
6+
/**
7+
* This error is thrown if the EngineSession does not manage to parse the required port successfully because a EOF is read before any valid port.
8+
* This usually happens if no connection can be established.
9+
*/
10+
export class EngineSessionError extends DaggerSDKError {
11+
name = ERROR_NAMES.EngineSessionError;
12+
code = ERROR_CODES.EngineSessionError;
13+
14+
/**
15+
* @hidden
16+
*/
17+
constructor(message: string, options?: EngineSessionErrorOptions) {
18+
super(message, options);
19+
}
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import { DaggerSDKError, DaggerSDKErrorOptions } from "./DaggerSDKError.ts";
2+
import { ERROR_CODES, ERROR_NAMES } from "./errors-codes.ts";
3+
4+
interface ExecErrorOptions extends DaggerSDKErrorOptions {
5+
cmd: string[];
6+
exitCode: number;
7+
stdout: string;
8+
stderr: string;
9+
}
10+
11+
/**
12+
* API error from an exec operation in a pipeline.
13+
*/
14+
export class ExecError extends DaggerSDKError {
15+
name = ERROR_NAMES.ExecError;
16+
code = ERROR_CODES.ExecError;
17+
18+
/**
19+
* The command that caused the error.
20+
*/
21+
cmd: string[];
22+
23+
/**
24+
* The exit code of the command.
25+
*/
26+
exitCode: number;
27+
28+
/**
29+
* The stdout of the command.
30+
*/
31+
stdout: string;
32+
33+
/**
34+
* The stderr of the command.
35+
*/
36+
stderr: string;
37+
38+
/**
39+
* @hidden
40+
*/
41+
constructor(message: string, options: ExecErrorOptions) {
42+
super(message, options);
43+
this.cmd = options.cmd;
44+
this.exitCode = options.exitCode;
45+
this.stdout = options.stdout;
46+
this.stderr = options.stderr;
47+
}
48+
49+
toString(): string {
50+
return `${super.toString()}\nStdout:\n${this.stdout}\nStderr:\n${
51+
this.stderr
52+
}`;
53+
}
54+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { GraphQLRequestContext, GraphQLResponse } from "./types.ts";
2+
3+
import { DaggerSDKError, DaggerSDKErrorOptions } from "./DaggerSDKError.ts";
4+
import { ERROR_CODES, ERROR_NAMES } from "./errors-codes.ts";
5+
6+
interface GraphQLRequestErrorOptions extends DaggerSDKErrorOptions {
7+
response: GraphQLResponse;
8+
request: GraphQLRequestContext;
9+
}
10+
11+
/**
12+
* This error originates from the dagger engine. It means that some error was thrown and sent back via GraphQL.
13+
*/
14+
export class GraphQLRequestError extends DaggerSDKError {
15+
name = ERROR_NAMES.GraphQLRequestError;
16+
code = ERROR_CODES.GraphQLRequestError;
17+
18+
/**
19+
* The query and variables, which caused the error.
20+
*/
21+
requestContext: GraphQLRequestContext;
22+
23+
/**
24+
* the GraphQL response containing the error.
25+
*/
26+
response: GraphQLResponse;
27+
28+
/**
29+
* @hidden
30+
*/
31+
constructor(message: string, options: GraphQLRequestErrorOptions) {
32+
super(message, options);
33+
this.requestContext = options.request;
34+
this.response = options.response;
35+
}
36+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { DaggerSDKError, DaggerSDKErrorOptions } from "./DaggerSDKError.ts";
2+
import { ERROR_CODES, ERROR_NAMES } from "./errors-codes.ts";
3+
4+
/**
5+
* This error is thrown if the dagger binary cannot be copied from the dagger docker image and copied to the local host.
6+
*/
7+
export class InitEngineSessionBinaryError extends DaggerSDKError {
8+
name = ERROR_NAMES.InitEngineSessionBinaryError;
9+
code = ERROR_CODES.InitEngineSessionBinaryError;
10+
11+
/**
12+
* @hidden
13+
*/
14+
constructor(message: string, options?: DaggerSDKErrorOptions) {
15+
super(message, options);
16+
}
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { DaggerSDKError, DaggerSDKErrorOptions } from "./DaggerSDKError.ts";
2+
import { ERROR_CODES, ERROR_NAMES } from "./errors-codes.ts";
3+
4+
/**
5+
* This error is thrown when the compute function isn't awaited.
6+
*/
7+
export class NotAwaitedRequestError extends DaggerSDKError {
8+
name = ERROR_NAMES.NotAwaitedRequestError;
9+
code = ERROR_CODES.NotAwaitedRequestError;
10+
11+
/**
12+
* @hidden
13+
*/
14+
constructor(message: string, options?: DaggerSDKErrorOptions) {
15+
super(message, options);
16+
}
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { DaggerSDKError, DaggerSDKErrorOptions } from "./DaggerSDKError.ts";
2+
import { ERROR_CODES, ERROR_NAMES } from "./errors-codes.ts";
3+
4+
interface TooManyNestedObjectsErrorOptions extends DaggerSDKErrorOptions {
5+
response: unknown;
6+
}
7+
8+
/**
9+
* Dagger only expects one response value from the engine. If the engine returns more than one value this error is thrown.
10+
*/
11+
export class TooManyNestedObjectsError extends DaggerSDKError {
12+
name = ERROR_NAMES.TooManyNestedObjectsError;
13+
code = ERROR_CODES.TooManyNestedObjectsError;
14+
15+
/**
16+
* the response containing more than one value.
17+
*/
18+
response: unknown;
19+
20+
/**
21+
* @hidden
22+
*/
23+
constructor(message: string, options: TooManyNestedObjectsErrorOptions) {
24+
super(message, options);
25+
this.response = options.response;
26+
}
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { DaggerSDKError, DaggerSDKErrorOptions } from "./DaggerSDKError.ts";
2+
import { ERROR_CODES, ERROR_NAMES } from "./errors-codes.ts";
3+
4+
/**
5+
* This error is thrown if the dagger SDK does not identify the error and just wraps the cause.
6+
*/
7+
export class UnknownDaggerError extends DaggerSDKError {
8+
name = ERROR_NAMES.UnknownDaggerError;
9+
code = ERROR_CODES.UnknownDaggerError;
10+
11+
/**
12+
* @hidden
13+
*/
14+
constructor(message: string, options: DaggerSDKErrorOptions) {
15+
super(message, options);
16+
}
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
export const ERROR_CODES = {
2+
/**
3+
* {@link GraphQLRequestError}
4+
*/
5+
GraphQLRequestError: "D100",
6+
7+
/**
8+
* {@link UnknownDaggerError}
9+
*/
10+
UnknownDaggerError: "D101",
11+
12+
/**
13+
* {@link TooManyNestedObjectsError}
14+
*/
15+
TooManyNestedObjectsError: "D102",
16+
17+
/**
18+
* {@link EngineSessionConnectParamsParseError}
19+
*/
20+
EngineSessionConnectParamsParseError: "D103",
21+
22+
/**
23+
* {@link EngineSessionConnectionTimeoutError}
24+
*/
25+
EngineSessionConnectionTimeoutError: "D104",
26+
27+
/**
28+
* {@link EngineSessionError}
29+
*/
30+
EngineSessionError: "D105",
31+
32+
/**
33+
* {@link InitEngineSessionBinaryError}
34+
*/
35+
InitEngineSessionBinaryError: "D106",
36+
37+
/**
38+
* {@link DockerImageRefValidationError}
39+
*/
40+
DockerImageRefValidationError: "D107",
41+
42+
/**
43+
* {@link NotAwaitedRequestError}
44+
*/
45+
NotAwaitedRequestError: "D108",
46+
47+
/**
48+
* (@link ExecError}
49+
*/
50+
ExecError: "D109",
51+
} as const
52+
53+
type ErrorCodesType = typeof ERROR_CODES
54+
export type ErrorNames = keyof ErrorCodesType
55+
export type ErrorCodes = ErrorCodesType[ErrorNames]
56+
57+
type ErrorNamesMap = { readonly [Key in ErrorNames]: Key }
58+
export const ERROR_NAMES: ErrorNamesMap = (
59+
Object.keys(ERROR_CODES) as Array<ErrorNames>
60+
).reduce<ErrorNamesMap>(
61+
(obj, item) => ({ ...obj, [item]: item }),
62+
{} as ErrorNamesMap
63+
)

0 commit comments

Comments
 (0)