BREAKING CHANGE(DockerHost): Rename array-returning get* methods to list* on DockerHost and related resource classes; update docs, tests and changelog

This commit is contained in:
2025-11-24 13:27:10 +00:00
parent 15e5dedae4
commit 08dbad47bc
12 changed files with 61 additions and 34 deletions

View File

@@ -48,7 +48,7 @@ await docker.ping();
console.log('✅ Docker is running');
// List all containers
const containers = await docker.getContainers();
const containers = await docker.listContainers();
console.log(`Found ${containers.length} containers`);
// Get a specific container and interact with it
@@ -71,7 +71,7 @@ The module follows a **Facade pattern** with `DockerHost` as the single entry po
const docker = new DockerHost({});
// All operations go through DockerHost
const containers = await docker.getContainers(); // List containers
const containers = await docker.listContainers(); // List containers
const container = await docker.getContainerById('id'); // Get specific container
const network = await docker.createNetwork({ Name: 'my-net' }); // Create network
const service = await docker.createService(descriptor); // Deploy service
@@ -181,7 +181,7 @@ async function waitForDocker(timeoutMs = 10000): Promise<void> {
```typescript
// Get all containers (running and stopped)
const containers = await docker.getContainers();
const containers = await docker.listContainers();
containers.forEach((container) => {
console.log(`Container: ${container.Names[0]}`);
@@ -406,7 +406,7 @@ writeStream.on('finish', () => {
#### List All Images
```typescript
const images = await docker.getImages();
const images = await docker.listImages();
images.forEach((img) => {
console.log(`Image: ${img.RepoTags ? img.RepoTags.join(', ') : '<none>'}`);
@@ -444,7 +444,7 @@ console.log(`Network created: ${network.Name} (${network.Id})`);
```typescript
// Get all networks
const networks = await docker.getNetworks();
const networks = await docker.listNetworks();
networks.forEach((net) => {
console.log(`Network: ${net.Name} (${net.Driver})`);
@@ -456,7 +456,7 @@ networks.forEach((net) => {
const appNetwork = await docker.getNetworkByName('my-app-network');
// Get containers connected to this network
const containers = await appNetwork.getContainersOnNetwork();
const containers = await appNetwork.listContainersOnNetwork();
console.log(`Containers on network: ${containers.length}`);
```
@@ -523,7 +523,7 @@ console.log(`Service deployed: ${service.ID}`);
```typescript
// List all services
const services = await docker.getServices();
const services = await docker.listServices();
services.forEach((service) => {
console.log(`Service: ${service.Spec.Name}`);
@@ -566,7 +566,7 @@ const secret = await docker.createSecret({
console.log(`Secret created: ${secret.ID}`);
// List all secrets
const secrets = await docker.getSecrets();
const secrets = await docker.listSecrets();
secrets.forEach((s) => {
console.log(`Secret: ${s.Spec.Name}`);
console.log(` Labels:`, s.Spec.Labels);
@@ -868,7 +868,7 @@ async function healthCheckService() {
try {
await docker.ping();
const containers = await docker.getContainers();
const containers = await docker.listContainers();
const unhealthy = containers.filter(c => c.State !== 'running');
if (unhealthy.length > 0) {