|
|
@@ -150,6 +150,38 @@ sendjob: |
|
|
|
return &getImagesResult, nil |
|
|
|
} |
|
|
|
|
|
|
|
func GetPublicImages() (*models.GetImagesResult, error) { |
|
|
|
checkSetting() |
|
|
|
client := getRestyClient() |
|
|
|
var getImagesResult models.GetImagesResult |
|
|
|
|
|
|
|
retry := 0 |
|
|
|
|
|
|
|
sendjob: |
|
|
|
res, err := client.R(). |
|
|
|
SetHeader("Content-Type", "application/json"). |
|
|
|
SetAuthToken(TOKEN). |
|
|
|
SetBody(map[string]interface{}{"pageIndex": 1, "pageSize": 50}). |
|
|
|
SetResult(&getImagesResult). |
|
|
|
Get(HOST + "/rest-server/api/v1/image/public/list/") |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
return nil, fmt.Errorf("resty GetPublicImages: %v", err) |
|
|
|
} |
|
|
|
|
|
|
|
if getImagesResult.Code == "S401" && retry < 1 { |
|
|
|
retry++ |
|
|
|
_ = loginCloudbrain() |
|
|
|
goto sendjob |
|
|
|
} |
|
|
|
|
|
|
|
if getImagesResult.Code != Success { |
|
|
|
return &getImagesResult, fmt.Errorf("getImgesResult err: %s", res.String()) |
|
|
|
} |
|
|
|
|
|
|
|
return &getImagesResult, nil |
|
|
|
} |
|
|
|
|
|
|
|
func CommitImage(jobID string, params models.CommitImageParams) error { |
|
|
|
checkSetting() |
|
|
|
client := getRestyClient() |
|
|
|