mirror of
				https://github.com/docker/compose.git
				synced 2025-10-30 18:53:51 +01:00 
			
		
		
		
	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" | ||||
| 	"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/preview/preview/subscription/mgmt/subscription" | ||||
| 	"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/pkg/errors" | ||||
| 
 | ||||
| 	"github.com/docker/api/azure/login" | ||||
| 	"github.com/docker/api/errdefs" | ||||
| 
 | ||||
| 	"github.com/docker/api/context/store" | ||||
| ) | ||||
| 
 | ||||
| @ -261,7 +262,7 @@ func getSubscriptionsClient() (subscription.SubscriptionsClient, error) { | ||||
| 	subc := subscription.NewSubscriptionsClient() | ||||
| 	authorizer, err := login.NewAuthorizerFromLogin() | ||||
| 	if err != nil { | ||||
| 		return subscription.SubscriptionsClient{}, err | ||||
| 		return subscription.SubscriptionsClient{}, errors.Wrap(errdefs.ErrLoginFailed, err.Error()) | ||||
| 	} | ||||
| 	subc.Authorizer = authorizer | ||||
| 	return subc, nil | ||||
|  | ||||
| @ -1,13 +1,16 @@ | ||||
| package convert | ||||
| 
 | ||||
| import ( | ||||
| 	"errors" | ||||
| 	"fmt" | ||||
| 	"net/url" | ||||
| 	"path/filepath" | ||||
| 	"strings" | ||||
| 
 | ||||
| 	"github.com/pkg/errors" | ||||
| 
 | ||||
| 	"github.com/compose-spec/compose-go/types" | ||||
| 
 | ||||
| 	"github.com/docker/api/errdefs" | ||||
| ) | ||||
| 
 | ||||
| // 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, ":") | ||||
| 	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 { | ||||
| 		tokens := strings.Split(pathURL, ":") | ||||
| @ -86,20 +89,20 @@ func volumeURL(pathURL string) (*url.URL, error) { | ||||
| func (v *volumeInput) parse(name string, s string) error { | ||||
| 	volumeURL, err := volumeURL(s) | ||||
| 	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() | ||||
| 	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() | ||||
| 	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.share = volumeURL.Host | ||||
| 	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.target = volumeURL.Path | ||||
|  | ||||
| @ -45,6 +45,8 @@ var ( | ||||
| 	// ErrNotImplemented is returned when a backend doesn't implement | ||||
| 	// an action | ||||
| 	ErrNotImplemented = errors.New("not implemented") | ||||
| 	// ErrParsingFailed | ||||
| 	ErrParsingFailed = errors.New("parsing failed") | ||||
| ) | ||||
| 
 | ||||
| // IsNotFoundError returns true if the unwrapped error is ErrNotFound | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user