Update containerd for config backward compatibility.
Signed-off-by: Lantao Liu <lantaol@google.com>
This commit is contained in:
parent
b5e9d13261
commit
0344ac239b
@ -2,7 +2,7 @@ github.com/beorn7/perks 4c0e84591b9aa9e6dcfdf3e020114cd81f89d5f9
|
|||||||
github.com/BurntSushi/toml v0.3.1
|
github.com/BurntSushi/toml v0.3.1
|
||||||
github.com/containerd/cgroups db272301ab8449d05f062e6db6f13d8a6aaff466
|
github.com/containerd/cgroups db272301ab8449d05f062e6db6f13d8a6aaff466
|
||||||
github.com/containerd/console 0650fd9eeb50bab4fc99dceb9f2e14cf58f36e7f
|
github.com/containerd/console 0650fd9eeb50bab4fc99dceb9f2e14cf58f36e7f
|
||||||
github.com/containerd/containerd 2f69be5594cecacdbe42076ed12c7039a0638a2c
|
github.com/containerd/containerd 31afff294400b5a69bdb3ec387ecdf5bad57a038
|
||||||
github.com/containerd/continuity bd77b46c8352f74eb12c85bdc01f4b90f69d66b4
|
github.com/containerd/continuity bd77b46c8352f74eb12c85bdc01f4b90f69d66b4
|
||||||
github.com/containerd/fifo 3d5202aec260678c48179c56f40e6f38a095738c
|
github.com/containerd/fifo 3d5202aec260678c48179c56f40e6f38a095738c
|
||||||
github.com/containerd/go-cni 22460c018b64cf8bf4151b3ff9c4d077e6a88cbf
|
github.com/containerd/go-cni 22460c018b64cf8bf4151b3ff9c4d077e6a88cbf
|
||||||
|
5
vendor/github.com/containerd/containerd/cmd/containerd/command/config.go
generated
vendored
5
vendor/github.com/containerd/containerd/cmd/containerd/command/config.go
generated
vendored
@ -50,6 +50,11 @@ var configCommand = cli.Command{
|
|||||||
config := &Config{
|
config := &Config{
|
||||||
Config: defaultConfig(),
|
Config: defaultConfig(),
|
||||||
}
|
}
|
||||||
|
// for the time being, keep the defaultConfig's version set at 1 so that
|
||||||
|
// when a config without a version is loaded from disk and has no version
|
||||||
|
// set, we assume it's a v1 config. But when generating new configs via
|
||||||
|
// this command, generate the v2 config
|
||||||
|
config.Config.Version = 2
|
||||||
plugins, err := server.LoadPlugins(gocontext.Background(), config.Config)
|
plugins, err := server.LoadPlugins(gocontext.Background(), config.Config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
2
vendor/github.com/containerd/containerd/cmd/containerd/command/config_linux.go
generated
vendored
2
vendor/github.com/containerd/containerd/cmd/containerd/command/config_linux.go
generated
vendored
@ -23,7 +23,7 @@ import (
|
|||||||
|
|
||||||
func defaultConfig() *srvconfig.Config {
|
func defaultConfig() *srvconfig.Config {
|
||||||
return &srvconfig.Config{
|
return &srvconfig.Config{
|
||||||
Version: 2,
|
Version: 1,
|
||||||
Root: defaults.DefaultRootDir,
|
Root: defaults.DefaultRootDir,
|
||||||
State: defaults.DefaultStateDir,
|
State: defaults.DefaultStateDir,
|
||||||
GRPC: srvconfig.GRPCConfig{
|
GRPC: srvconfig.GRPCConfig{
|
||||||
|
2
vendor/github.com/containerd/containerd/cmd/containerd/command/config_unsupported.go
generated
vendored
2
vendor/github.com/containerd/containerd/cmd/containerd/command/config_unsupported.go
generated
vendored
@ -25,7 +25,7 @@ import (
|
|||||||
|
|
||||||
func defaultConfig() *srvconfig.Config {
|
func defaultConfig() *srvconfig.Config {
|
||||||
return &srvconfig.Config{
|
return &srvconfig.Config{
|
||||||
Version: 2,
|
Version: 1,
|
||||||
Root: defaults.DefaultRootDir,
|
Root: defaults.DefaultRootDir,
|
||||||
State: defaults.DefaultStateDir,
|
State: defaults.DefaultStateDir,
|
||||||
GRPC: srvconfig.GRPCConfig{
|
GRPC: srvconfig.GRPCConfig{
|
||||||
|
2
vendor/github.com/containerd/containerd/cmd/containerd/command/config_windows.go
generated
vendored
2
vendor/github.com/containerd/containerd/cmd/containerd/command/config_windows.go
generated
vendored
@ -23,7 +23,7 @@ import (
|
|||||||
|
|
||||||
func defaultConfig() *srvconfig.Config {
|
func defaultConfig() *srvconfig.Config {
|
||||||
return &srvconfig.Config{
|
return &srvconfig.Config{
|
||||||
Version: 2,
|
Version: 1,
|
||||||
Root: defaults.DefaultRootDir,
|
Root: defaults.DefaultRootDir,
|
||||||
State: defaults.DefaultStateDir,
|
State: defaults.DefaultStateDir,
|
||||||
GRPC: srvconfig.GRPCConfig{
|
GRPC: srvconfig.GRPCConfig{
|
||||||
|
22
vendor/github.com/containerd/containerd/remotes/docker/authorizer.go
generated
vendored
22
vendor/github.com/containerd/containerd/remotes/docker/authorizer.go
generated
vendored
@ -31,6 +31,7 @@ import (
|
|||||||
|
|
||||||
"github.com/containerd/containerd/errdefs"
|
"github.com/containerd/containerd/errdefs"
|
||||||
"github.com/containerd/containerd/log"
|
"github.com/containerd/containerd/log"
|
||||||
|
"github.com/containerd/containerd/version"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"golang.org/x/net/context/ctxhttp"
|
"golang.org/x/net/context/ctxhttp"
|
||||||
@ -40,6 +41,7 @@ type dockerAuthorizer struct {
|
|||||||
credentials func(string) (string, string, error)
|
credentials func(string) (string, string, error)
|
||||||
|
|
||||||
client *http.Client
|
client *http.Client
|
||||||
|
ua string
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
|
|
||||||
auth map[string]string
|
auth map[string]string
|
||||||
@ -54,6 +56,7 @@ func NewAuthorizer(client *http.Client, f func(string) (string, string, error))
|
|||||||
return &dockerAuthorizer{
|
return &dockerAuthorizer{
|
||||||
credentials: f,
|
credentials: f,
|
||||||
client: client,
|
client: client,
|
||||||
|
ua: "containerd/" + version.Version,
|
||||||
auth: map[string]string{},
|
auth: map[string]string{},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -194,11 +197,16 @@ func (a *dockerAuthorizer) fetchTokenWithOAuth(ctx context.Context, to tokenOpti
|
|||||||
form.Set("password", to.secret)
|
form.Set("password", to.secret)
|
||||||
}
|
}
|
||||||
|
|
||||||
resp, err := ctxhttp.Post(
|
req, err := http.NewRequest("POST", to.realm, strings.NewReader(form.Encode()))
|
||||||
ctx, a.client, to.realm,
|
if err != nil {
|
||||||
"application/x-www-form-urlencoded; charset=utf-8",
|
return "", err
|
||||||
strings.NewReader(form.Encode()),
|
}
|
||||||
)
|
req.Header.Set("Content-Type", "application/x-www-form-urlencoded; charset=utf-8")
|
||||||
|
if a.ua != "" {
|
||||||
|
req.Header.Set("User-Agent", a.ua)
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := ctxhttp.Do(ctx, a.client, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
@ -244,6 +252,10 @@ func (a *dockerAuthorizer) fetchToken(ctx context.Context, to tokenOptions) (str
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if a.ua != "" {
|
||||||
|
req.Header.Set("User-Agent", a.ua)
|
||||||
|
}
|
||||||
|
|
||||||
reqParams := req.URL.Query()
|
reqParams := req.URL.Query()
|
||||||
|
|
||||||
if to.service != "" {
|
if to.service != "" {
|
||||||
|
14
vendor/github.com/containerd/containerd/remotes/docker/resolver.go
generated
vendored
14
vendor/github.com/containerd/containerd/remotes/docker/resolver.go
generated
vendored
@ -111,6 +111,7 @@ type dockerResolver struct {
|
|||||||
auth Authorizer
|
auth Authorizer
|
||||||
host func(string) (string, error)
|
host func(string) (string, error)
|
||||||
headers http.Header
|
headers http.Header
|
||||||
|
uagent string
|
||||||
plainHTTP bool
|
plainHTTP bool
|
||||||
client *http.Client
|
client *http.Client
|
||||||
tracker StatusTracker
|
tracker StatusTracker
|
||||||
@ -135,16 +136,22 @@ func NewResolver(options ResolverOptions) remotes.Resolver {
|
|||||||
ocispec.MediaTypeImageManifest,
|
ocispec.MediaTypeImageManifest,
|
||||||
ocispec.MediaTypeImageIndex, "*"}, ", "))
|
ocispec.MediaTypeImageIndex, "*"}, ", "))
|
||||||
}
|
}
|
||||||
if _, ok := options.Headers["User-Agent"]; !ok {
|
ua := options.Headers.Get("User-Agent")
|
||||||
options.Headers.Set("User-Agent", "containerd/"+version.Version)
|
if ua != "" {
|
||||||
|
options.Headers.Del("User-Agent")
|
||||||
|
} else {
|
||||||
|
ua = "containerd/" + version.Version
|
||||||
}
|
}
|
||||||
|
|
||||||
if options.Authorizer == nil {
|
if options.Authorizer == nil {
|
||||||
options.Authorizer = NewAuthorizer(options.Client, options.Credentials)
|
options.Authorizer = NewAuthorizer(options.Client, options.Credentials)
|
||||||
|
options.Authorizer.(*dockerAuthorizer).ua = ua
|
||||||
}
|
}
|
||||||
return &dockerResolver{
|
return &dockerResolver{
|
||||||
auth: options.Authorizer,
|
auth: options.Authorizer,
|
||||||
host: options.Host,
|
host: options.Host,
|
||||||
headers: options.Headers,
|
headers: options.Headers,
|
||||||
|
uagent: ua,
|
||||||
plainHTTP: options.PlainHTTP,
|
plainHTTP: options.PlainHTTP,
|
||||||
client: options.Client,
|
client: options.Client,
|
||||||
tracker: options.Tracker,
|
tracker: options.Tracker,
|
||||||
@ -351,6 +358,7 @@ func (r *dockerResolver) Pusher(ctx context.Context, ref string) (remotes.Pusher
|
|||||||
type dockerBase struct {
|
type dockerBase struct {
|
||||||
refspec reference.Spec
|
refspec reference.Spec
|
||||||
base url.URL
|
base url.URL
|
||||||
|
uagent string
|
||||||
|
|
||||||
client *http.Client
|
client *http.Client
|
||||||
auth Authorizer
|
auth Authorizer
|
||||||
@ -382,6 +390,7 @@ func (r *dockerResolver) base(refspec reference.Spec) (*dockerBase, error) {
|
|||||||
return &dockerBase{
|
return &dockerBase{
|
||||||
refspec: refspec,
|
refspec: refspec,
|
||||||
base: base,
|
base: base,
|
||||||
|
uagent: r.uagent,
|
||||||
client: r.client,
|
client: r.client,
|
||||||
auth: r.auth,
|
auth: r.auth,
|
||||||
}, nil
|
}, nil
|
||||||
@ -407,6 +416,7 @@ func (r *dockerBase) authorize(ctx context.Context, req *http.Request) error {
|
|||||||
func (r *dockerBase) doRequest(ctx context.Context, req *http.Request) (*http.Response, error) {
|
func (r *dockerBase) doRequest(ctx context.Context, req *http.Request) (*http.Response, error) {
|
||||||
ctx = log.WithLogger(ctx, log.G(ctx).WithField("url", req.URL.String()))
|
ctx = log.WithLogger(ctx, log.G(ctx).WithField("url", req.URL.String()))
|
||||||
log.G(ctx).WithField("request.headers", req.Header).WithField("request.method", req.Method).Debug("do request")
|
log.G(ctx).WithField("request.headers", req.Header).WithField("request.method", req.Method).Debug("do request")
|
||||||
|
req.Header.Set("User-Agent", r.uagent)
|
||||||
if err := r.authorize(ctx, req); err != nil {
|
if err := r.authorize(ctx, req); err != nil {
|
||||||
return nil, errors.Wrap(err, "failed to authorize")
|
return nil, errors.Wrap(err, "failed to authorize")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user