|
|
|
@@ -702,6 +702,55 @@ func CloudBrainCommitImageCheck(ctx *context.Context, form auth.CommitImageCloud |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
func CloudBrainAdminCommitImage(ctx *context.Context, form auth.CommitAdminImageCloudBrainForm) { |
|
|
|
|
|
|
|
if !NamePattern.MatchString(form.Tag) { |
|
|
|
ctx.JSON(http.StatusOK, models.BaseErrorMessage(ctx.Tr("dataset.title_format_err"))) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
if utf8.RuneCountInString(form.Description) > 255 { |
|
|
|
ctx.JSON(http.StatusOK, models.BaseErrorMessage(ctx.Tr("dataset.description_format_err", 255))) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
validTopics, errMessage := checkTopics(form.Topics) |
|
|
|
if errMessage != "" { |
|
|
|
ctx.JSON(http.StatusOK, models.BaseErrorMessage(ctx.Tr(errMessage))) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
err := cloudbrain.CommitAdminImage(ctx.Cloudbrain.JobID, models.CommitImageParams{ |
|
|
|
CommitImageCloudBrainParams: models.CommitImageCloudBrainParams{ |
|
|
|
Ip: ctx.Cloudbrain.ContainerIp, |
|
|
|
TaskContainerId: ctx.Cloudbrain.ContainerID, |
|
|
|
ImageDescription: form.Description, |
|
|
|
ImageTag: form.Tag, |
|
|
|
}, |
|
|
|
IsPrivate: form.IsPrivate, |
|
|
|
CloudBrainType: form.Type, |
|
|
|
Topics: validTopics, |
|
|
|
UID: ctx.User.ID, |
|
|
|
Type: models.GetRecommondType(form.IsRecommend), |
|
|
|
Place: form.Place, |
|
|
|
}) |
|
|
|
if err != nil { |
|
|
|
log.Error("CommitImage(%s) failed:%v", ctx.Cloudbrain.JobName, err.Error(), ctx.Data["msgID"]) |
|
|
|
if models.IsErrImageTagExist(err) { |
|
|
|
ctx.JSON(200, models.BaseErrorMessage(ctx.Tr("repo.image_exist"))) |
|
|
|
|
|
|
|
} else if models.IsErrorImageCommitting(err) { |
|
|
|
ctx.JSON(200, models.BaseErrorMessage(ctx.Tr("repo.image_committing"))) |
|
|
|
} else { |
|
|
|
ctx.JSON(200, models.BaseErrorMessage(ctx.Tr("repo.image_commit_fail"))) |
|
|
|
} |
|
|
|
|
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
ctx.JSON(200, models.BaseOKMessage) |
|
|
|
} |
|
|
|
|
|
|
|
func CloudBrainCommitImage(ctx *context.Context, form auth.CommitImageCloudBrainForm) { |
|
|
|
|
|
|
|
if !NamePattern.MatchString(form.Tag) { |
|
|
|
|