chore(images): initialise Docker service with containerd client

This commit is contained in:
Pasha Sviderski
2025-10-02 15:51:54 +10:00
parent 92975eec51
commit 59074a275f
5 changed files with 78 additions and 32 deletions
+39
View File
@@ -0,0 +1,39 @@
package containerd
import (
"fmt"
"time"
"github.com/containerd/containerd/v2/client"
)
// Client is a containerd client for image operations.
type Client struct {
Client *client.Client
}
// NewClient creates a new containerd client connected to the given socket path.
func NewClient(sockPath string) (*Client, error) {
if sockPath == "" {
return nil, fmt.Errorf("containerd socket path is required")
}
c, err := client.New(
sockPath,
client.WithDefaultNamespace("moby"),
client.WithTimeout(60*time.Second),
)
if err != nil {
return nil, err
}
return &Client{Client: c}, nil
}
// Close closes the containerd client connection.
func (c *Client) Close() error {
if c.Client != nil {
return c.Client.Close()
}
return nil
}