@@ -18,10 +18,13 @@ package commands
18
18
19
19
import (
20
20
gocontext "context"
21
+ "os"
22
+ "strconv"
21
23
22
24
containerd "github.com/containerd/containerd/v2/client"
23
25
"github.com/containerd/containerd/v2/pkg/epoch"
24
26
"github.com/containerd/containerd/v2/pkg/namespaces"
27
+ ptypes "github.com/containerd/containerd/v2/protobuf/types"
25
28
"github.com/containerd/log"
26
29
"github.com/urfave/cli"
27
30
)
@@ -62,5 +65,22 @@ func NewClient(context *cli.Context, opts ...containerd.Opt) (*containerd.Client
62
65
return nil , nil , nil , err
63
66
}
64
67
ctx , cancel := AppContext (context )
68
+ var suppressDeprecationWarnings bool
69
+ if s := os .Getenv ("CONTAINERD_SUPPRESS_DEPRECATION_WARNINGS" ); s != "" {
70
+ suppressDeprecationWarnings , err = strconv .ParseBool (s )
71
+ if err != nil {
72
+ log .L .WithError (err ).Warn ("Failed to parse CONTAINERD_SUPPRESS_DEPRECATION_WARNINGS=" + s )
73
+ }
74
+ }
75
+ if ! suppressDeprecationWarnings {
76
+ resp , err := client .IntrospectionService ().Server (ctx , & ptypes.Empty {})
77
+ if err != nil {
78
+ log .L .WithError (err ).Warn ("Failed to check deprecations" )
79
+ } else {
80
+ for _ , d := range resp .Deprecations {
81
+ log .L .Warn ("DEPRECATION: " + d .Message )
82
+ }
83
+ }
84
+ }
65
85
return client , ctx , cancel , nil
66
86
}
0 commit comments