mirror of
https://github.com/moby/moby.git
synced 2026-01-11 10:41:43 +00:00
client: un-export NewVersionError, rename to requiresVersion
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -53,12 +53,12 @@ func (e objectNotFoundError) Error() string {
|
|||||||
return fmt.Sprintf("Error: No such %s: %s", e.object, e.id)
|
return fmt.Sprintf("Error: No such %s: %s", e.object, e.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewVersionError returns an error if the APIVersion required is less than the
|
// requiresVersion returns an error if the APIVersion required is less than the
|
||||||
// current supported version.
|
// current supported version.
|
||||||
//
|
//
|
||||||
// It performs API-version negotiation if the Client is configured with this
|
// It performs API-version negotiation if the Client is configured with this
|
||||||
// option, otherwise it assumes the latest API version is used.
|
// option, otherwise it assumes the latest API version is used.
|
||||||
func (cli *Client) NewVersionError(ctx context.Context, APIrequired, feature string) error {
|
func (cli *Client) requiresVersion(ctx context.Context, apiRequired, feature string) error {
|
||||||
// Make sure we negotiated (if the client is configured to do so),
|
// Make sure we negotiated (if the client is configured to do so),
|
||||||
// as code below contains API-version specific handling of options.
|
// as code below contains API-version specific handling of options.
|
||||||
//
|
//
|
||||||
@@ -67,8 +67,8 @@ func (cli *Client) NewVersionError(ctx context.Context, APIrequired, feature str
|
|||||||
if err := cli.checkVersion(ctx); err != nil {
|
if err := cli.checkVersion(ctx); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if cli.version != "" && versions.LessThan(cli.version, APIrequired) {
|
if cli.version != "" && versions.LessThan(cli.version, apiRequired) {
|
||||||
return fmt.Errorf("%q requires API version %s, but the Docker daemon API version is %s", feature, APIrequired, cli.version)
|
return fmt.Errorf("%q requires API version %s, but the Docker daemon API version is %s", feature, apiRequired, cli.version)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ func (cli *Client) ImageHistory(ctx context.Context, imageID string, historyOpts
|
|||||||
}
|
}
|
||||||
|
|
||||||
if opts.apiOptions.Platform != nil {
|
if opts.apiOptions.Platform != nil {
|
||||||
if err := cli.NewVersionError(ctx, "1.48", "platform"); err != nil {
|
if err := cli.requiresVersion(ctx, "1.48", "platform"); err != nil {
|
||||||
return ImageHistoryResult{}, err
|
return ImageHistoryResult{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,14 +24,14 @@ func (cli *Client) ImageInspect(ctx context.Context, imageID string, inspectOpts
|
|||||||
|
|
||||||
query := url.Values{}
|
query := url.Values{}
|
||||||
if opts.apiOptions.Manifests {
|
if opts.apiOptions.Manifests {
|
||||||
if err := cli.NewVersionError(ctx, "1.48", "manifests"); err != nil {
|
if err := cli.requiresVersion(ctx, "1.48", "manifests"); err != nil {
|
||||||
return ImageInspectResult{}, err
|
return ImageInspectResult{}, err
|
||||||
}
|
}
|
||||||
query.Set("manifests", "1")
|
query.Set("manifests", "1")
|
||||||
}
|
}
|
||||||
|
|
||||||
if opts.apiOptions.Platform != nil {
|
if opts.apiOptions.Platform != nil {
|
||||||
if err := cli.NewVersionError(ctx, "1.49", "platform"); err != nil {
|
if err := cli.requiresVersion(ctx, "1.49", "platform"); err != nil {
|
||||||
return ImageInspectResult{}, err
|
return ImageInspectResult{}, err
|
||||||
}
|
}
|
||||||
platform, err := encodePlatform(opts.apiOptions.Platform)
|
platform, err := encodePlatform(opts.apiOptions.Platform)
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ func (cli *Client) ImageLoad(ctx context.Context, input io.Reader, loadOpts ...I
|
|||||||
query.Set("quiet", "1")
|
query.Set("quiet", "1")
|
||||||
}
|
}
|
||||||
if len(opts.apiOptions.Platforms) > 0 {
|
if len(opts.apiOptions.Platforms) > 0 {
|
||||||
if err := cli.NewVersionError(ctx, "1.48", "platform"); err != nil {
|
if err := cli.requiresVersion(ctx, "1.48", "platform"); err != nil {
|
||||||
return ImageLoadResult{}, err
|
return ImageLoadResult{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ func (cli *Client) ImagePush(ctx context.Context, image string, options ImagePus
|
|||||||
}
|
}
|
||||||
|
|
||||||
if options.Platform != nil {
|
if options.Platform != nil {
|
||||||
if err := cli.NewVersionError(ctx, "1.46", "platform"); err != nil {
|
if err := cli.requiresVersion(ctx, "1.46", "platform"); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ func (cli *Client) ImageSave(ctx context.Context, imageIDs []string, saveOpts ..
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(opts.apiOptions.Platforms) > 0 {
|
if len(opts.apiOptions.Platforms) > 0 {
|
||||||
if err := cli.NewVersionError(ctx, "1.48", "platform"); err != nil {
|
if err := cli.requiresVersion(ctx, "1.48", "platform"); err != nil {
|
||||||
return ImageSaveResult{}, err
|
return ImageSaveResult{}, err
|
||||||
}
|
}
|
||||||
p, err := encodePlatforms(opts.apiOptions.Platforms...)
|
p, err := encodePlatforms(opts.apiOptions.Platforms...)
|
||||||
|
|||||||
8
vendor/github.com/moby/moby/client/errors.go
generated
vendored
8
vendor/github.com/moby/moby/client/errors.go
generated
vendored
@@ -53,12 +53,12 @@ func (e objectNotFoundError) Error() string {
|
|||||||
return fmt.Sprintf("Error: No such %s: %s", e.object, e.id)
|
return fmt.Sprintf("Error: No such %s: %s", e.object, e.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewVersionError returns an error if the APIVersion required is less than the
|
// requiresVersion returns an error if the APIVersion required is less than the
|
||||||
// current supported version.
|
// current supported version.
|
||||||
//
|
//
|
||||||
// It performs API-version negotiation if the Client is configured with this
|
// It performs API-version negotiation if the Client is configured with this
|
||||||
// option, otherwise it assumes the latest API version is used.
|
// option, otherwise it assumes the latest API version is used.
|
||||||
func (cli *Client) NewVersionError(ctx context.Context, APIrequired, feature string) error {
|
func (cli *Client) requiresVersion(ctx context.Context, apiRequired, feature string) error {
|
||||||
// Make sure we negotiated (if the client is configured to do so),
|
// Make sure we negotiated (if the client is configured to do so),
|
||||||
// as code below contains API-version specific handling of options.
|
// as code below contains API-version specific handling of options.
|
||||||
//
|
//
|
||||||
@@ -67,8 +67,8 @@ func (cli *Client) NewVersionError(ctx context.Context, APIrequired, feature str
|
|||||||
if err := cli.checkVersion(ctx); err != nil {
|
if err := cli.checkVersion(ctx); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if cli.version != "" && versions.LessThan(cli.version, APIrequired) {
|
if cli.version != "" && versions.LessThan(cli.version, apiRequired) {
|
||||||
return fmt.Errorf("%q requires API version %s, but the Docker daemon API version is %s", feature, APIrequired, cli.version)
|
return fmt.Errorf("%q requires API version %s, but the Docker daemon API version is %s", feature, apiRequired, cli.version)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
2
vendor/github.com/moby/moby/client/image_history.go
generated
vendored
2
vendor/github.com/moby/moby/client/image_history.go
generated
vendored
@@ -32,7 +32,7 @@ func (cli *Client) ImageHistory(ctx context.Context, imageID string, historyOpts
|
|||||||
}
|
}
|
||||||
|
|
||||||
if opts.apiOptions.Platform != nil {
|
if opts.apiOptions.Platform != nil {
|
||||||
if err := cli.NewVersionError(ctx, "1.48", "platform"); err != nil {
|
if err := cli.requiresVersion(ctx, "1.48", "platform"); err != nil {
|
||||||
return ImageHistoryResult{}, err
|
return ImageHistoryResult{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
4
vendor/github.com/moby/moby/client/image_inspect.go
generated
vendored
4
vendor/github.com/moby/moby/client/image_inspect.go
generated
vendored
@@ -24,14 +24,14 @@ func (cli *Client) ImageInspect(ctx context.Context, imageID string, inspectOpts
|
|||||||
|
|
||||||
query := url.Values{}
|
query := url.Values{}
|
||||||
if opts.apiOptions.Manifests {
|
if opts.apiOptions.Manifests {
|
||||||
if err := cli.NewVersionError(ctx, "1.48", "manifests"); err != nil {
|
if err := cli.requiresVersion(ctx, "1.48", "manifests"); err != nil {
|
||||||
return ImageInspectResult{}, err
|
return ImageInspectResult{}, err
|
||||||
}
|
}
|
||||||
query.Set("manifests", "1")
|
query.Set("manifests", "1")
|
||||||
}
|
}
|
||||||
|
|
||||||
if opts.apiOptions.Platform != nil {
|
if opts.apiOptions.Platform != nil {
|
||||||
if err := cli.NewVersionError(ctx, "1.49", "platform"); err != nil {
|
if err := cli.requiresVersion(ctx, "1.49", "platform"); err != nil {
|
||||||
return ImageInspectResult{}, err
|
return ImageInspectResult{}, err
|
||||||
}
|
}
|
||||||
platform, err := encodePlatform(opts.apiOptions.Platform)
|
platform, err := encodePlatform(opts.apiOptions.Platform)
|
||||||
|
|||||||
2
vendor/github.com/moby/moby/client/image_load.go
generated
vendored
2
vendor/github.com/moby/moby/client/image_load.go
generated
vendored
@@ -28,7 +28,7 @@ func (cli *Client) ImageLoad(ctx context.Context, input io.Reader, loadOpts ...I
|
|||||||
query.Set("quiet", "1")
|
query.Set("quiet", "1")
|
||||||
}
|
}
|
||||||
if len(opts.apiOptions.Platforms) > 0 {
|
if len(opts.apiOptions.Platforms) > 0 {
|
||||||
if err := cli.NewVersionError(ctx, "1.48", "platform"); err != nil {
|
if err := cli.requiresVersion(ctx, "1.48", "platform"); err != nil {
|
||||||
return ImageLoadResult{}, err
|
return ImageLoadResult{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
2
vendor/github.com/moby/moby/client/image_push.go
generated
vendored
2
vendor/github.com/moby/moby/client/image_push.go
generated
vendored
@@ -50,7 +50,7 @@ func (cli *Client) ImagePush(ctx context.Context, image string, options ImagePus
|
|||||||
}
|
}
|
||||||
|
|
||||||
if options.Platform != nil {
|
if options.Platform != nil {
|
||||||
if err := cli.NewVersionError(ctx, "1.46", "platform"); err != nil {
|
if err := cli.requiresVersion(ctx, "1.46", "platform"); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
2
vendor/github.com/moby/moby/client/image_save.go
generated
vendored
2
vendor/github.com/moby/moby/client/image_save.go
generated
vendored
@@ -24,7 +24,7 @@ func (cli *Client) ImageSave(ctx context.Context, imageIDs []string, saveOpts ..
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(opts.apiOptions.Platforms) > 0 {
|
if len(opts.apiOptions.Platforms) > 0 {
|
||||||
if err := cli.NewVersionError(ctx, "1.48", "platform"); err != nil {
|
if err := cli.requiresVersion(ctx, "1.48", "platform"); err != nil {
|
||||||
return ImageSaveResult{}, err
|
return ImageSaveResult{}, err
|
||||||
}
|
}
|
||||||
p, err := encodePlatforms(opts.apiOptions.Platforms...)
|
p, err := encodePlatforms(opts.apiOptions.Platforms...)
|
||||||
|
|||||||
Reference in New Issue
Block a user