@@ -25,10 +25,8 @@ import (
25
25
)
26
26
27
27
const (
28
- // RepositoriesURL path to the Hub API listing the repositories
29
- RepositoriesURL = "/v2/repositories/%s/"
30
- // DeleteRepositoryURL path to the Hub API to remove a repository
31
- DeleteRepositoryURL = "/v2/repositories/%s/"
28
+ // RepositoriesURL is the Hub API base URL
29
+ RepositoriesURL = "/v2/repositories/"
32
30
)
33
31
34
32
//Repository represents a Docker Hub repository
@@ -46,7 +44,8 @@ func (c *Client) GetRepositories(account string) ([]Repository, int, error) {
46
44
if account == "" {
47
45
account = c .account
48
46
}
49
- u , err := url .Parse (c .domain + fmt .Sprintf (RepositoriesURL , account ))
47
+ repositoriesURL := fmt .Sprintf ("%s%s%s" , c .domain , RepositoriesURL , account )
48
+ u , err := url .Parse (repositoriesURL )
50
49
if err != nil {
51
50
return nil , 0 , err
52
51
}
@@ -77,12 +76,17 @@ func (c *Client) GetRepositories(account string) ([]Repository, int, error) {
77
76
78
77
//RemoveRepository removes a repository on Hub
79
78
func (c * Client ) RemoveRepository (repository string ) error {
80
- req , err := http .NewRequest ("DELETE" , c .domain + fmt .Sprintf (DeleteRepositoryURL , repository ), nil )
79
+ repositoryURL := fmt .Sprintf ("%s%s%s/" , c .domain , RepositoriesURL , repository )
80
+ req , err := http .NewRequest (http .MethodDelete , repositoryURL , nil )
81
81
if err != nil {
82
82
return err
83
83
}
84
84
_ , err = c .doRequest (req , withHubToken (c .token ))
85
- return err
85
+ if err != nil {
86
+ return err
87
+ }
88
+
89
+ return nil
86
90
}
87
91
88
92
func (c * Client ) getRepositoriesPage (url , account string ) ([]Repository , int , string , error ) {
0 commit comments