mirror of https://github.com/docker/compose.git
Implement ErrParsingFailed error
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
This commit is contained in:
parent
bdd987f246
commit
b68c019e93
|
@ -9,8 +9,6 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/docker/api/azure/login"
|
|
||||||
|
|
||||||
"github.com/Azure/azure-sdk-for-go/profiles/2019-03-01/resources/mgmt/resources"
|
"github.com/Azure/azure-sdk-for-go/profiles/2019-03-01/resources/mgmt/resources"
|
||||||
"github.com/Azure/azure-sdk-for-go/profiles/preview/preview/subscription/mgmt/subscription"
|
"github.com/Azure/azure-sdk-for-go/profiles/preview/preview/subscription/mgmt/subscription"
|
||||||
"github.com/Azure/azure-sdk-for-go/services/containerinstance/mgmt/2018-10-01/containerinstance"
|
"github.com/Azure/azure-sdk-for-go/services/containerinstance/mgmt/2018-10-01/containerinstance"
|
||||||
|
@ -21,6 +19,9 @@ import (
|
||||||
"github.com/gobwas/ws/wsutil"
|
"github.com/gobwas/ws/wsutil"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
|
"github.com/docker/api/azure/login"
|
||||||
|
"github.com/docker/api/errdefs"
|
||||||
|
|
||||||
"github.com/docker/api/context/store"
|
"github.com/docker/api/context/store"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -261,7 +262,7 @@ func getSubscriptionsClient() (subscription.SubscriptionsClient, error) {
|
||||||
subc := subscription.NewSubscriptionsClient()
|
subc := subscription.NewSubscriptionsClient()
|
||||||
authorizer, err := login.NewAuthorizerFromLogin()
|
authorizer, err := login.NewAuthorizerFromLogin()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return subscription.SubscriptionsClient{}, err
|
return subscription.SubscriptionsClient{}, errors.Wrap(errdefs.ErrLoginFailed, err.Error())
|
||||||
}
|
}
|
||||||
subc.Authorizer = authorizer
|
subc.Authorizer = authorizer
|
||||||
return subc, nil
|
return subc, nil
|
||||||
|
|
|
@ -1,13 +1,16 @@
|
||||||
package convert
|
package convert
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/url"
|
"net/url"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
"github.com/compose-spec/compose-go/types"
|
"github.com/compose-spec/compose-go/types"
|
||||||
|
|
||||||
|
"github.com/docker/api/errdefs"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetRunVolumes return volume configurations for a project and a single service
|
// GetRunVolumes return volume configurations for a project and a single service
|
||||||
|
@ -74,7 +77,7 @@ func volumeURL(pathURL string) (*url.URL, error) {
|
||||||
|
|
||||||
count := strings.Count(pathURL, ":")
|
count := strings.Count(pathURL, ":")
|
||||||
if count > 2 {
|
if count > 2 {
|
||||||
return nil, fmt.Errorf("unable to parse volume mount %q", pathURL)
|
return nil, errors.Wrap(errdefs.ErrParsingFailed, fmt.Sprintf("unable to parse volume mount %q", pathURL))
|
||||||
}
|
}
|
||||||
if count == 2 {
|
if count == 2 {
|
||||||
tokens := strings.Split(pathURL, ":")
|
tokens := strings.Split(pathURL, ":")
|
||||||
|
@ -86,20 +89,20 @@ func volumeURL(pathURL string) (*url.URL, error) {
|
||||||
func (v *volumeInput) parse(name string, s string) error {
|
func (v *volumeInput) parse(name string, s string) error {
|
||||||
volumeURL, err := volumeURL(s)
|
volumeURL, err := volumeURL(s)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("volume specification %q could not be parsed %q", s, err)
|
return errors.Wrap(errdefs.ErrParsingFailed, fmt.Sprintf("volume specification %q could not be parsed %q", s, err))
|
||||||
}
|
}
|
||||||
v.username = volumeURL.User.Username()
|
v.username = volumeURL.User.Username()
|
||||||
if v.username == "" {
|
if v.username == "" {
|
||||||
return fmt.Errorf("volume specification %q does not include a storage username", v)
|
return errors.Wrap(errdefs.ErrParsingFailed, fmt.Sprintf("volume specification %q does not include a storage username", v))
|
||||||
}
|
}
|
||||||
key, ok := volumeURL.User.Password()
|
key, ok := volumeURL.User.Password()
|
||||||
if !ok || key == "" {
|
if !ok || key == "" {
|
||||||
return fmt.Errorf("volume specification %q does not include a storage key", v)
|
return errors.Wrap(errdefs.ErrParsingFailed, fmt.Sprintf("volume specification %q does not include a storage key", v))
|
||||||
}
|
}
|
||||||
v.key = unescapeKey(key)
|
v.key = unescapeKey(key)
|
||||||
v.share = volumeURL.Host
|
v.share = volumeURL.Host
|
||||||
if v.share == "" {
|
if v.share == "" {
|
||||||
return fmt.Errorf("volume specification %q does not include a storage file share", v)
|
return errors.Wrap(errdefs.ErrParsingFailed, fmt.Sprintf("volume specification %q does not include a storage file share", v))
|
||||||
}
|
}
|
||||||
v.name = name
|
v.name = name
|
||||||
v.target = volumeURL.Path
|
v.target = volumeURL.Path
|
||||||
|
|
|
@ -45,6 +45,8 @@ var (
|
||||||
// ErrNotImplemented is returned when a backend doesn't implement
|
// ErrNotImplemented is returned when a backend doesn't implement
|
||||||
// an action
|
// an action
|
||||||
ErrNotImplemented = errors.New("not implemented")
|
ErrNotImplemented = errors.New("not implemented")
|
||||||
|
// ErrParsingFailed
|
||||||
|
ErrParsingFailed = errors.New("parsing failed")
|
||||||
)
|
)
|
||||||
|
|
||||||
// IsNotFoundError returns true if the unwrapped error is ErrNotFound
|
// IsNotFoundError returns true if the unwrapped error is ErrNotFound
|
||||||
|
|
Loading…
Reference in New Issue