Skip to content

Commit 1af0cba

Browse files
committed
Update documentation for containerd v2.0 packages
Signed-off-by: Austin Vazquez <[email protected]>
1 parent 134dc87 commit 1af0cba

10 files changed

+52
-42
lines changed

README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
![containerd banner light mode](https://raw.githubusercontent.com/cncf/artwork/master/projects/containerd/horizontal/color/containerd-horizontal-color.png#gh-light-mode-only)
22
![containerd banner dark mode](https://raw.githubusercontent.com/cncf/artwork/master/projects/containerd/horizontal/white/containerd-horizontal-white.png#gh-dark-mode-only)
33

4-
[![PkgGoDev](https://pkg.go.dev/badge/github.com/containerd/containerd)](https://pkg.go.dev/github.com/containerd/containerd)
4+
[![PkgGoDev](https://pkg.go.dev/badge/github.com/containerd/containerd/v2)](https://pkg.go.dev/github.com/containerd/containerd/v2)
55
[![Build Status](https://github.com/containerd/containerd/workflows/CI/badge.svg)](https://github.com/containerd/containerd/actions?query=workflow%3ACI)
66
[![Nightlies](https://github.com/containerd/containerd/workflows/Nightly/badge.svg)](https://github.com/containerd/containerd/actions?query=workflow%3ANightly)
7-
[![Go Report Card](https://goreportcard.com/badge/github.com/containerd/containerd)](https://goreportcard.com/report/github.com/containerd/containerd)
7+
[![Go Report Card](https://goreportcard.com/badge/github.com/containerd/containerd/v2)](https://goreportcard.com/report/github.com/containerd/containerd/v2)
88
[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/1271/badge)](https://bestpractices.coreinfrastructure.org/projects/1271)
99

1010
containerd is an industry-standard container runtime with an emphasis on simplicity, robustness, and portability. It is available as a daemon for Linux and Windows, which can manage the complete container lifecycle of its host system: image transfer and storage, container execution and supervision, low-level storage and network attachments, etc.
@@ -107,9 +107,9 @@ containerd offers a full client package to help you integrate containerd into yo
107107
import (
108108
"context"
109109

110-
"github.com/containerd/containerd"
111-
"github.com/containerd/containerd/cio"
112-
"github.com/containerd/containerd/namespaces"
110+
containerd "github.com/containerd/containerd/v2/client"
111+
"github.com/containerd/containerd/v2/cio"
112+
"github.com/containerd/containerd/v2/namespaces"
113113
)
114114

115115

RELEASES.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ containerd versions:
240240
| Runtime Shim API | Stable | 1.2 | - |
241241
| Daemon Config | Stable | 1.0 | - |
242242
| CRI GRPC API | Stable | 1.6 (_CRI v1_) | [cri-api](https://github.com/kubernetes/cri-api/tree/master/pkg/apis/runtime/v1) |
243-
| Go client API | Unstable | _future_ | [godoc](https://godoc.org/github.com/containerd/containerd) |
243+
| Go client API | Unstable | _future_ | [godoc](https://godoc.org/github.com/containerd/containerd/v2/client) |
244244
| `ctr` tool | Unstable | Out of scope | - |
245245

246246
From the version stated in the above table, that component must adhere to the
@@ -308,7 +308,7 @@ follow that format.
308308
### Go client API
309309

310310
The Go client API, documented in
311-
[godoc](https://godoc.org/github.com/containerd/containerd), is currently
311+
[godoc](https://godoc.org/github.com/containerd/containerd/v2/client), is currently
312312
considered unstable. It is recommended to vendor the necessary components to
313313
stabilize your project build. Note that because the Go API interfaces with the
314314
GRPC API, clients written against a 1.0 Go API should remain compatible with

docs/PLUGINS.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ with an image registry, or loading an image from tar. containerd's Go client
1313
gives a user access to many points of extensions from creating their own
1414
options on container creation to resolving image registry names.
1515

16-
See [containerd's Go documentation](https://godoc.org/github.com/containerd/containerd)
16+
See [containerd's Go documentation](https://godoc.org/github.com/containerd/containerd/v2/client)
1717

1818
## External Plugins
1919

@@ -75,11 +75,11 @@ version = 2
7575

7676
Implementing a proxy plugin is as easy as implementing the gRPC API for a
7777
service. For implementing a proxy plugin in Go, look at the go doc for
78-
[content store service](https://godoc.org/github.com/containerd/containerd/api/services/content/v1#ContentServer), [snapshotter service](https://godoc.org/github.com/containerd/containerd/api/services/snapshots/v1#SnapshotsServer), and [diff service](https://pkg.go.dev/github.com/containerd/containerd/api/services/diff/v1#DiffServer).
78+
[content store service](https://godoc.org/github.com/containerd/containerd/v2/api/services/content/v1#ContentServer), [snapshotter service](https://godoc.org/github.com/containerd/containerd/v2/api/services/snapshots/v1#SnapshotsServer), and [diff service](https://pkg.go.dev/github.com/containerd/containerd/v2/api/services/diff/v1#DiffServer).
7979

8080
The following example creates a snapshot plugin binary which can be used
8181
with any implementation of
82-
[containerd's Snapshotter interface](https://godoc.org/github.com/containerd/containerd/snapshots#Snapshotter)
82+
[containerd's Snapshotter interface](https://godoc.org/github.com/containerd/containerd/v2/snapshots#Snapshotter)
8383
```go
8484
package main
8585

@@ -90,9 +90,9 @@ import (
9090

9191
"google.golang.org/grpc"
9292

93-
snapshotsapi "github.com/containerd/containerd/api/services/snapshots/v1"
94-
"github.com/containerd/containerd/contrib/snapshotservice"
95-
"github.com/containerd/containerd/snapshots/native"
93+
snapshotsapi "github.com/containerd/containerd/v2/api/services/snapshots/v1"
94+
"github.com/containerd/containerd/v2/contrib/snapshotservice"
95+
"github.com/containerd/containerd/v2/snapshots/native"
9696
)
9797

9898
func main() {

docs/client-opts.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ If we want to make a `SpecOpt` to setup a container to monitor the host system w
6565
package monitor
6666

6767
import (
68-
"github.com/containerd/containerd/oci"
68+
"github.com/containerd/containerd/v2/oci"
6969
specs "github.com/opencontainers/runtime-spec/specs-go"
7070
)
7171

docs/content-flow.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -422,12 +422,12 @@ in turn, depends on the next layer down, so it is protected from collection, and
422422
### Container
423423

424424
With the above in place, we know how to create an active snapshot that is useful for the container. We simply
425-
need to [Prepare()](https://godoc.org/github.com/containerd/containerd/snapshots#Snapshotter) the active snapshot,
425+
need to [Prepare()](https://godoc.org/github.com/containerd/containerd/v2/snapshots#Snapshotter) the active snapshot,
426426
passing it an ID and the parent, in this case the top layer of committed snapshots.
427427

428428
Thus, the steps are:
429429

430-
1. Get the content into the content store, either via [Pull()](https://godoc.org/github.com/containerd/containerd#Client.Pull), or via loading it in the [content.Store API](https://godoc.org/github.com/containerd/containerd/content#Store)
431-
1. Unpack the image to create committed snapshots for each layer, using [image.Unpack()](https://godoc.org/github.com/containerd/containerd#Image). Alternatively, if you use [Pull()](https://godoc.org/github.com/containerd/containerd#Client.Pull), you can pass it an option to unpack when pulling, using [WithPullUnpack()](https://godoc.org/github.com/containerd/containerd#WithPullUnpack)
432-
1. Create an active snapshot using [Prepare()](https://godoc.org/github.com/containerd/containerd/snapshots#Snapshotter). You can skip this step if you plan on creating a container, as you can pass it as an option to the next step.
433-
1. Create a container using [NewContainer()](https://godoc.org/github.com/containerd/containerd#Client.NewContainer), optionally telling it to create a snapshot with [WithNewSnapshot()](https://godoc.org/github.com/containerd/containerd#WithNewSnapshot)
430+
1. Get the content into the content store, either via [Pull()](https://godoc.org/github.com/containerd/containerd/v2/client#Client.Pull), or via loading it in the [content.Store API](https://godoc.org/github.com/containerd/containerd/v2/content#Store)
431+
1. Unpack the image to create committed snapshots for each layer, using [image.Unpack()](https://godoc.org/github.com/containerd/containerd/v2/client#Image). Alternatively, if you use [Pull()](https://godoc.org/github.com/containerd/containerd/v2/client#Client.Pull), you can pass it an option to unpack when pulling, using [WithPullUnpack()](https://godoc.org/github.com/containerd/containerd/v2/client#WithPullUnpack)
432+
1. Create an active snapshot using [Prepare()](https://godoc.org/github.com/containerd/containerd/v2/snapshots#Snapshotter). You can skip this step if you plan on creating a container, as you can pass it as an option to the next step.
433+
1. Create a container using [NewContainer()](https://godoc.org/github.com/containerd/containerd/v2/client#Client.NewContainer), optionally telling it to create a snapshot with [WithNewSnapshot()](https://godoc.org/github.com/containerd/containerd/v2/client#WithNewSnapshot)

docs/garbage-collection.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
longer being used. The client is responsible for ensuring that all resources
55
which are created are either used or held by a lease at all times, else they
66
will be considered eligible for removal. The Go client library
7-
(`github.com/containerd/containerd`) has built-in behavior to ensure resources
7+
(`github.com/containerd/containerd/v2/client`) has built-in behavior to ensure resources
88
are properly tracked and leased. However, the lifecycles of leases are the
99
responsibility of the caller of the library. The `containerd` daemon has strict
1010
resource management and will garbage collect any unused resource.
@@ -43,7 +43,7 @@ _But, of course, more complicated use cases are supported..._
4343
If the program or lease are intended to be longer lived, instead of the very
4444
easy `client.WithLease`, the lease manager can be used directly. This also
4545
allows for setting custom labels on the lease or manipulating its resources.
46-
Use `client.LeasesService()` to get a [lease Manager](https://godoc.org/github.com/containerd/containerd/leases#Manager)
46+
Use `client.LeasesService()` to get a [lease Manager](https://godoc.org/github.com/containerd/containerd/v2/leases#Manager)
4747
which can be used to create, list, and delete leases as well as manage the
4848
referenced resources for that lease.
4949

@@ -157,9 +157,9 @@ may also request a garbage collection during resource removal. In this case,
157157
the garbage collection will be scheduled immediately (or after `schedule_delay`
158158
when configured to non-zero). The service will not return until the garbage
159159
collection has completed. This is currently supported on removal of images and
160-
leases. Use [`images.SynchronousDelete()`](https://godoc.org/github.com/containerd/containerd/images#SynchronousDelete)
161-
for [`images.Store`](https://godoc.org/github.com/containerd/containerd/images#Store)'s
160+
leases. Use [`images.SynchronousDelete()`](https://godoc.org/github.com/containerd/containerd/v2/images#SynchronousDelete)
161+
for [`images.Store`](https://godoc.org/github.com/containerd/containerd/v2/images#Store)'s
162162
`Delete` and
163-
[`leases.SynchronousDelete`](https://godoc.org/github.com/containerd/containerd/leases#SynchronousDelete)
164-
for [`leases.Manager`](https://godoc.org/github.com/containerd/containerd/leases#Manager)'s
163+
[`leases.SynchronousDelete`](https://godoc.org/github.com/containerd/containerd/v2/leases#SynchronousDelete)
164+
for [`leases.Manager`](https://godoc.org/github.com/containerd/containerd/v2/leases#Manager)'s
165165
`Delete`.

docs/getting-started.md

+12-12
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ See the header of [`go.mod`](https://github.com/containerd/containerd/blob/main/
189189

190190
### Connecting to containerd
191191

192-
We will start a new `main.go` file and import the containerd root package that contains the client.
192+
We will start a new `main.go` file and import the containerd client package.
193193

194194

195195
```go
@@ -198,7 +198,7 @@ package main
198198
import (
199199
"log"
200200

201-
"github.com/containerd/containerd"
201+
containerd "github.com/containerd/containerd/v2/client"
202202
)
203203

204204
func main() {
@@ -252,8 +252,8 @@ import (
252252
"context"
253253
"log"
254254

255-
"github.com/containerd/containerd"
256-
"github.com/containerd/containerd/namespaces"
255+
containerd "github.com/containerd/containerd/v2/client"
256+
"github.com/containerd/containerd/v2/namespaces"
257257
)
258258

259259
func main() {
@@ -327,9 +327,9 @@ import (
327327
"context"
328328
"log"
329329

330-
"github.com/containerd/containerd"
331-
"github.com/containerd/containerd/oci"
332-
"github.com/containerd/containerd/namespaces"
330+
containerd "github.com/containerd/containerd/v2/client"
331+
"github.com/containerd/containerd/v2/namespaces"
332+
"github.com/containerd/containerd/v2/oci"
333333
)
334334

335335
func main() {
@@ -474,10 +474,10 @@ import (
474474
"syscall"
475475
"time"
476476

477-
"github.com/containerd/containerd"
478-
"github.com/containerd/containerd/cio"
479-
"github.com/containerd/containerd/oci"
480-
"github.com/containerd/containerd/namespaces"
477+
"github.com/containerd/containerd/v2/cio"
478+
containerd "github.com/containerd/containerd/v2/client"
479+
"github.com/containerd/containerd/v2/oci"
480+
"github.com/containerd/containerd/v2/namespaces"
481481
)
482482

483483
func main() {
@@ -526,7 +526,7 @@ func redisExample() error {
526526
// make sure we wait before calling start
527527
exitStatusC, err := task.Wait(ctx)
528528
if err != nil {
529-
fmt.Println(err)
529+
return err
530530
}
531531

532532
// call start on the task to execute the redis server

docs/namespaces.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ It is trivial for clients to switch namespaces.
1212
## Who specifies the namespace?
1313

1414
The client specifies the namespace via the `context`.
15-
There is a `github.com/containerd/containerd/namespaces` package that allows a user to get and set the namespace on a context.
15+
There is a `github.com/containerd/containerd/v2/namespaces` package that allows a user to get and set the namespace on a context.
1616

1717
```go
1818
// set a namespace

docs/ops.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ USAGE:
1919
containerd [global options] command [command options] [arguments...]
2020
2121
VERSION:
22-
v1.7.0-beta.0
22+
v2.0.0-beta.0
2323
2424
DESCRIPTION:
2525

docs/remote-snapshotter.md

+13-3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ The containerd client's `Pull` API with unpacking-mode allows the underlying sna
1515
Remote snapshotter needs to be plugged into containerd in [the same ways as normal snapshotters](/docs/PLUGINS.md).
1616

1717
```go
18+
import (
19+
containerd "github.com/containerd/containerd/v2/client"
20+
)
21+
1822
image, err := client.Pull(ctx, ref,
1923
containerd.WithPullUnpack,
2024
containerd.WithPullSnapshotter("my-remote-snapshotter"),
@@ -39,7 +43,10 @@ This is useful if the values of these labels are determined statically regardles
3943
These user-defined labels must be prefixed by `containerd.io/snapshot/`.
4044

4145
```go
42-
import "github.com/containerd/containerd/snapshots"
46+
import (
47+
containerd "github.com/containerd/containerd/v2/client"
48+
"github.com/containerd/containerd/v2/snapshots"
49+
)
4350

4451
image, err := client.Pull(ctx, ref,
4552
containerd.WithPullUnpack,
@@ -61,10 +68,13 @@ Every time the containerd client queries remote snapshot, it passes `Annotations
6168
These annotations are passed to the snapshotter as user-defined labels.
6269
The values of annotations can be dynamically added and modified in the handler wrapper.
6370
Note that annotations must be prefixed by `containerd.io/snapshot/`.
64-
`github.com/containerd/containerd/pkg/snapshotters` is a handler implementation used by the CRI package, nerdctl and moby.
71+
`github.com/containerd/containerd/v2/pkg/snapshotters` is a handler implementation used by the CRI package, nerdctl and moby.
6572

6673
```go
67-
import "github.com/containerd/containerd/pkg/snapshotters"
74+
import (
75+
containerd "github.com/containerd/containerd/v2/client"
76+
"github.com/containerd/containerd/v2/pkg/snapshotters"
77+
)
6878

6979
if _, err := client.Pull(ctx, ref,
7080
containerd.WithPullUnpack,

0 commit comments

Comments
 (0)