Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
271 changes: 192 additions & 79 deletions lib/docker-client.ts

Large diffs are not rendered by default.

36 changes: 31 additions & 5 deletions lib/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,30 @@ export class ConflictError extends Error {
}
}

// Function to parse content-type header and extract charset parameter
function parseContentType(contentType?: string): {
type: string;
charset?: string;
} {
if (!contentType) {
return { type: '' };
}

const parts = contentType.split(';').map((part) => part.trim());
const type = parts[0]?.toLowerCase() || '';

let charset: string | undefined;
for (let i = 1; i < parts.length; i++) {
const param = parts[i]?.toLowerCase() || '';
if (param.startsWith('charset=')) {
charset = param.split('=')[1];
break;
}
}

return { type, charset };
}

// Function to extract error message from response body
function getErrorMessageFromResp(
res: http.IncomingMessage,
Expand Down Expand Up @@ -77,7 +101,7 @@ export class HTTPClient {
options?: {
params?: Record<string, any>;
data?: any;
callback?: (data: Buffer) => void;
callback?: (data: Buffer, encoding?: string) => void;
accept?: string;
headers?: Record<string, string>;
},
Expand Down Expand Up @@ -191,14 +215,16 @@ export class HTTPClient {

// Check for Docker stream content types
const contentType = res.headers['content-type'];
const { type: mimeType, charset } =
parseContentType(contentType);
const isDockerStream =
contentType === DOCKER_RAW_STREAM ||
contentType === DOCKER_MULTIPLEXED_STREAM;
mimeType === DOCKER_RAW_STREAM ||
mimeType === DOCKER_MULTIPLEXED_STREAM;

if (isDockerStream && callback) {
// For upgrade protocols, forward all data directly to callback
res.on('data', (data: Buffer) => {
callback(data);
callback(data, charset || 'utf8');
});

// Resolve immediately with upgrade response
Expand All @@ -212,7 +238,7 @@ export class HTTPClient {
callback
) {
res.on('data', (chunk: Buffer) => {
callback(chunk);
callback(chunk, charset);
});

res.on('end', () => handleResponseEnd());
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions lib/models/AuthConfig.ts → lib/types/AuthConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
*/

export interface AuthConfig {
Username?: string;
username?: string;

Password?: string;
password?: string;

/**
* Email is an optional value associated with the username. &gt; **Deprecated**: This field is deprecated since docker 1.11 (API v1.23) and will be removed in a future release.
*/
Email?: string;
email?: string;

Serveraddress?: string;
serveraddress?: string;
}
File renamed without changes.
18 changes: 9 additions & 9 deletions lib/models/BuildInfo.ts → lib/types/BuildInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@
Do not edit the class manually.
*/

import { type ErrorDetail } from '../models/ErrorDetail.js';
import { type ImageID } from '../models/ImageID.js';
import { type ProgressDetail } from '../models/ProgressDetail.js';
import { type ErrorDetail } from '../types/ErrorDetail.js';
import { type ImageID } from '../types/ImageID.js';
import { type ProgressDetail } from '../types/ProgressDetail.js';

export interface BuildInfo {
Id?: string;
id?: string;

Stream?: string;
stream?: string;

ErrorDetail?: ErrorDetail;
errorDetail?: ErrorDetail;

Status?: string;
status?: string;

ProgressDetail?: ProgressDetail;
progressDetail?: ProgressDetail;

Aux?: ImageID;
aux?: ImageID;
}
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions lib/models/ClusterInfo.ts → lib/types/ClusterInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
Do not edit the class manually.
*/

import { type ObjectVersion } from '../models/ObjectVersion.js';
import { type SwarmSpec } from '../models/SwarmSpec.js';
import { type TLSInfo } from '../models/TLSInfo.js';
import { type ObjectVersion } from '../types/ObjectVersion.js';
import { type SwarmSpec } from '../types/SwarmSpec.js';
import { type TLSInfo } from '../types/TLSInfo.js';

/**
* ClusterInfo represents information about the swarm as is returned by the \"/info\" endpoint. Join-tokens are not included.
Expand Down
8 changes: 4 additions & 4 deletions lib/models/ClusterVolume.ts → lib/types/ClusterVolume.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
Do not edit the class manually.
*/

import { type ClusterVolumeInfo } from '../models/ClusterVolumeInfo.js';
import { type ClusterVolumePublishStatusInner } from '../models/ClusterVolumePublishStatusInner.js';
import { type ClusterVolumeSpec } from '../models/ClusterVolumeSpec.js';
import { type ObjectVersion } from '../models/ObjectVersion.js';
import { type ClusterVolumeInfo } from '../types/ClusterVolumeInfo.js';
import { type ClusterVolumePublishStatusInner } from '../types/ClusterVolumePublishStatusInner.js';
import { type ClusterVolumeSpec } from '../types/ClusterVolumeSpec.js';
import { type ObjectVersion } from '../types/ObjectVersion.js';

/**
* Options and information specific to, and only present on, Swarm CSI cluster volumes.
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
Do not edit the class manually.
*/

import { type ClusterVolumeSpecAccessMode } from '../models/ClusterVolumeSpecAccessMode.js';
import { type ClusterVolumeSpecAccessMode } from '../types/ClusterVolumeSpecAccessMode.js';

/**
* Cluster-specific options used to create the volume.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
Do not edit the class manually.
*/

import { type ClusterVolumeSpecAccessModeAccessibilityRequirements } from '../models/ClusterVolumeSpecAccessModeAccessibilityRequirements.js';
import { type ClusterVolumeSpecAccessModeCapacityRange } from '../models/ClusterVolumeSpecAccessModeCapacityRange.js';
import { type ClusterVolumeSpecAccessModeSecretsInner } from '../models/ClusterVolumeSpecAccessModeSecretsInner.js';
import { type ClusterVolumeSpecAccessModeAccessibilityRequirements } from '../types/ClusterVolumeSpecAccessModeAccessibilityRequirements.js';
import { type ClusterVolumeSpecAccessModeCapacityRange } from '../types/ClusterVolumeSpecAccessModeCapacityRange.js';
import { type ClusterVolumeSpecAccessModeSecretsInner } from '../types/ClusterVolumeSpecAccessModeSecretsInner.js';

/**
* Defines how the volume is used by tasks.
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions lib/models/Config.ts → lib/types/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
Do not edit the class manually.
*/

import { type ConfigSpec } from '../models/ConfigSpec.js';
import { type ObjectVersion } from '../models/ObjectVersion.js';
import { type ConfigSpec } from '../types/ConfigSpec.js';
import { type ObjectVersion } from '../types/ObjectVersion.js';

export interface Config {
ID?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
Do not edit the class manually.
*/

import { type Driver } from '../models/Driver.js';
import { type Driver } from '../types/Driver.js';

export interface ConfigCreateRequest {
/**
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion lib/models/ConfigSpec.ts → lib/types/ConfigSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
Do not edit the class manually.
*/

import { type Driver } from '../models/Driver.js';
import { type Driver } from '../types/Driver.js';

export interface ConfigSpec {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
* Blkio stats entry. This type is Linux-specific and omitted for Windows containers.
*/
export interface ContainerBlkioStatEntry {
Major?: number;
major?: number;

Minor?: number;
minor?: number;

Op?: string;
op?: string;

Value?: number;
value?: number;
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,46 +18,46 @@
Do not edit the class manually.
*/

import { type ContainerBlkioStatEntry } from '../models/ContainerBlkioStatEntry.js';
import { type ContainerBlkioStatEntry } from '../types/ContainerBlkioStatEntry.js';

/**
* BlkioStats stores all IO service stats for data read and write. This type is Linux-specific and holds many fields that are specific to cgroups v1. On a cgroup v2 host, all fields other than `io_service_bytes_recursive` are omitted or `null`. This type is only populated on Linux and omitted for Windows containers.
*/
export interface ContainerBlkioStats {
IoServiceBytesRecursive?: Array<ContainerBlkioStatEntry>;
io_service_bytes_recursive?: Array<ContainerBlkioStatEntry>;

/**
* This field is only available when using Linux containers with cgroups v1. It is omitted or &#x60;null&#x60; when using cgroups v2.
*/
IoServicedRecursive?: Array<ContainerBlkioStatEntry> | null;
io_serviced_recursive?: Array<ContainerBlkioStatEntry> | null;

/**
* This field is only available when using Linux containers with cgroups v1. It is omitted or &#x60;null&#x60; when using cgroups v2.
*/
IoQueueRecursive?: Array<ContainerBlkioStatEntry> | null;
io_queue_recursive?: Array<ContainerBlkioStatEntry> | null;

/**
* This field is only available when using Linux containers with cgroups v1. It is omitted or &#x60;null&#x60; when using cgroups v2.
*/
IoServiceTimeRecursive?: Array<ContainerBlkioStatEntry> | null;
io_service_time_recursive?: Array<ContainerBlkioStatEntry> | null;

/**
* This field is only available when using Linux containers with cgroups v1. It is omitted or &#x60;null&#x60; when using cgroups v2.
*/
IoWaitTimeRecursive?: Array<ContainerBlkioStatEntry> | null;
io_wait_time_recursive?: Array<ContainerBlkioStatEntry> | null;

/**
* This field is only available when using Linux containers with cgroups v1. It is omitted or &#x60;null&#x60; when using cgroups v2.
*/
IoMergedRecursive?: Array<ContainerBlkioStatEntry> | null;
io_merged_recursive?: Array<ContainerBlkioStatEntry> | null;

/**
* This field is only available when using Linux containers with cgroups v1. It is omitted or &#x60;null&#x60; when using cgroups v2.
*/
IoTimeRecursive?: Array<ContainerBlkioStatEntry> | null;
io_time_recursive?: Array<ContainerBlkioStatEntry> | null;

/**
* This field is only available when using Linux containers with cgroups v1. It is omitted or &#x60;null&#x60; when using cgroups v2.
*/
SectorsRecursive?: Array<ContainerBlkioStatEntry> | null;
sectors_recursive?: Array<ContainerBlkioStatEntry> | null;
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,24 @@
Do not edit the class manually.
*/

import { type ContainerCPUUsage } from '../models/ContainerCPUUsage.js';
import { type ContainerThrottlingData } from '../models/ContainerThrottlingData.js';
import { type ContainerCPUUsage } from '../types/ContainerCPUUsage.js';
import { type ContainerThrottlingData } from '../types/ContainerThrottlingData.js';

/**
* CPU related info of the container
*/
export interface ContainerCPUStats {
CpuUsage?: ContainerCPUUsage | null;
cpu_usage?: ContainerCPUUsage | null;

/**
* System Usage. This field is Linux-specific and omitted for Windows containers.
*/
SystemCpuUsage?: number | null;
system_cpu_usage?: number | null;

/**
* Number of online CPUs. This field is Linux-specific and omitted for Windows containers.
*/
OnlineCpus?: number | null;
online_cpus?: number | null;

ThrottlingData?: ContainerThrottlingData | null;
throttling_data?: ContainerThrottlingData | null;
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,20 @@ export interface ContainerCPUUsage {
/**
* Total CPU time consumed in nanoseconds (Linux) or 100\&#39;s of nanoseconds (Windows).
*/
TotalUsage?: number;
total_usage?: number;

/**
* Total CPU time (in nanoseconds) consumed per core (Linux). This field is Linux-specific when using cgroups v1. It is omitted when using cgroups v2 and Windows containers.
*/
PercpuUsage?: Array<number> | null;
percpu_usage?: Array<number> | null;

/**
* Time (in nanoseconds) spent by tasks of the cgroup in kernel mode (Linux), or time spent (in 100\&#39;s of nanoseconds) by all container processes in kernel mode (Windows). Not populated for Windows containers using Hyper-V isolation.
*/
UsageInKernelmode?: number;
usage_in_kernelmode?: number;

/**
* Time (in nanoseconds) spent by tasks of the cgroup in user mode (Linux), or time spent (in 100\&#39;s of nanoseconds) by all container processes in kernel mode (Windows). Not populated for Windows containers using Hyper-V isolation.
*/
UsageInUsermode?: number;
usage_in_usermode?: number;
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
Do not edit the class manually.
*/

import { type HealthConfig } from '../models/HealthConfig.js';
import { type HealthConfig } from '../types/HealthConfig.js';

/**
* Configuration for a container that is portable between hosts.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
Do not edit the class manually.
*/

import { type HealthConfig } from '../models/HealthConfig.js';
import { type HostConfig } from '../models/HostConfig.js';
import { type NetworkingConfig } from '../models/NetworkingConfig.js';
import { type HealthConfig } from '../types/HealthConfig.js';
import { type HostConfig } from '../types/HostConfig.js';
import { type NetworkingConfig } from '../types/NetworkingConfig.js';

export interface ContainerCreateRequest {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
Do not edit the class manually.
*/

import { type ContainerConfig } from '../models/ContainerConfig.js';
import { type ContainerState } from '../models/ContainerState.js';
import { type DriverData } from '../models/DriverData.js';
import { type HostConfig } from '../models/HostConfig.js';
import { type MountPoint } from '../models/MountPoint.js';
import { type NetworkSettings } from '../models/NetworkSettings.js';
import { type OCIDescriptor } from '../models/OCIDescriptor.js';
import { type ContainerConfig } from '../types/ContainerConfig.js';
import { type ContainerState } from '../types/ContainerState.js';
import { type DriverData } from '../types/DriverData.js';
import { type HostConfig } from '../types/HostConfig.js';
import { type MountPoint } from '../types/MountPoint.js';
import { type NetworkSettings } from '../types/NetworkSettings.js';
import { type OCIDescriptor } from '../types/OCIDescriptor.js';

export interface ContainerInspectResponse {
/**
Expand Down
Loading