mirror of https://github.com/docker/docs.git
Updating apiClient version using server version
Signed-off-by: Nishant Totla <nishanttotla@gmail.com>
This commit is contained in:
parent
cbb7c27621
commit
012dffeee3
|
|
@ -347,6 +347,10 @@ func (client *MockClient) ServerVersion(ctx context.Context) (types.Version, err
|
||||||
return args.Get(0).(types.Version), args.Error(1)
|
return args.Get(0).(types.Version), args.Error(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UpdateClientVersion updates the client version
|
||||||
|
func (client *MockClient) UpdateClientVersion(v string) {
|
||||||
|
}
|
||||||
|
|
||||||
// VolumeCreate creates a volume in the docker host
|
// VolumeCreate creates a volume in the docker host
|
||||||
func (client *MockClient) VolumeCreate(ctx context.Context, options types.VolumeCreateRequest) (types.Volume, error) {
|
func (client *MockClient) VolumeCreate(ctx context.Context, options types.VolumeCreateRequest) (types.Volume, error) {
|
||||||
args := client.Mock.Called(ctx, options)
|
args := client.Mock.Called(ctx, options)
|
||||||
|
|
|
||||||
|
|
@ -297,6 +297,10 @@ func (client *NopClient) ServerVersion(ctx context.Context) (types.Version, erro
|
||||||
return types.Version{}, errNoEngine
|
return types.Version{}, errNoEngine
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UpdateClientVersion updates the client version
|
||||||
|
func (client *NopClient) UpdateClientVersion(v string) {
|
||||||
|
}
|
||||||
|
|
||||||
// VolumeCreate creates a volume in the docker host
|
// VolumeCreate creates a volume in the docker host
|
||||||
func (client *NopClient) VolumeCreate(ctx context.Context, options types.VolumeCreateRequest) (types.Volume, error) {
|
func (client *NopClient) VolumeCreate(ctx context.Context, options types.VolumeCreateRequest) (types.Volume, error) {
|
||||||
return types.Volume{}, errNoEngine
|
return types.Volume{}, errNoEngine
|
||||||
|
|
|
||||||
|
|
@ -414,6 +414,26 @@ func (e *Engine) CheckConnectionErr(err error) {
|
||||||
// other errors may be ambiguous.
|
// other errors may be ambiguous.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update API Version in apiClient
|
||||||
|
func (e *Engine) updateClientVersionFromServer(serverVersion string) {
|
||||||
|
// v will be >= 1.6, since this is checked earlier
|
||||||
|
v := version.Version(serverVersion)
|
||||||
|
switch {
|
||||||
|
case v.LessThan(version.Version("1.7")):
|
||||||
|
e.apiClient.UpdateClientVersion("1.18")
|
||||||
|
case v.LessThan(version.Version("1.8")):
|
||||||
|
e.apiClient.UpdateClientVersion("1.19")
|
||||||
|
case v.LessThan(version.Version("1.9")):
|
||||||
|
e.apiClient.UpdateClientVersion("1.20")
|
||||||
|
case v.LessThan(version.Version("1.10")):
|
||||||
|
e.apiClient.UpdateClientVersion("1.21")
|
||||||
|
case v.LessThan(version.Version("1.11")):
|
||||||
|
e.apiClient.UpdateClientVersion("1.22")
|
||||||
|
default:
|
||||||
|
e.apiClient.UpdateClientVersion("1.23")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Gather engine specs (CPU, memory, constraints, ...).
|
// Gather engine specs (CPU, memory, constraints, ...).
|
||||||
func (e *Engine) updateSpecs() error {
|
func (e *Engine) updateSpecs() error {
|
||||||
info, err := e.apiClient.Info(context.TODO())
|
info, err := e.apiClient.Info(context.TODO())
|
||||||
|
|
@ -441,8 +461,10 @@ func (e *Engine) updateSpecs() error {
|
||||||
e.CheckConnectionErr(err)
|
e.CheckConnectionErr(err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// update version
|
// update server version
|
||||||
e.Version = v.Version
|
e.Version = v.Version
|
||||||
|
// update client version. engine-api handles backward compatibility where needed
|
||||||
|
e.updateClientVersionFromServer(v.Version)
|
||||||
|
|
||||||
e.Lock()
|
e.Lock()
|
||||||
defer e.Unlock()
|
defer e.Unlock()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue