Skip to content

Commit

Permalink
close #30
Browse files Browse the repository at this point in the history
  • Loading branch information
mkuchin committed Apr 26, 2016
1 parent 3b8598e commit fb0a97e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,25 @@ class RepositoryController {
}
*/
log.info "Deleting manifest"
restService.delete("${name}/manifests/${digest}")
//todo: show error/success
} else
def result = restService.delete("${name}/manifests/${digest}")
if (!result.deleted) {
def text = ''
try {
boolean unsupported = result.response.json.errors[0].code == 'UNSUPPORTED'
text = unsupported ? "Deletion disabled in registry, <a href='https://docs.docker.com/registry/configuration/#delete'>more info</a>." : result.text
} catch (e) {
text = result.text
}
flash.message = "Error deleting ${name}:${tag}: ${text}"
} else {
flash.message = "Tag ${name}:${tag} has been deleted"
flash.success = true
}
} else {
log.warn 'Readonly mode!'
flash.message = "Readonly mode!"
}
flash.deleteAction = true
redirect action: 'tags', id: params.name
}
}
5 changes: 4 additions & 1 deletion grails-app/services/docker/registry/web/RestService.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ class RestService {
def delete(String path) {
def rest = new RestBuilder()
def res = rest.delete("${registryUrl}/${path}", requestCustomizer)
log.info res.statusCode

def statusCode = res.statusCode
log.info statusCode
[deleted: statusCode.'2xxSuccessful', response: res]
}

void init() {
Expand Down
6 changes: 5 additions & 1 deletion grails-app/views/repository/tags.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@
<li><g:link action="index">Home</g:link></li>
<li class="active">${params.id.decodeURL()}</li>
</ol>

<g:if test="${flash.deleteAction}">
<div class="alert alert-${flash.success ? 'success' : 'danger'}" role="alert">
${raw(flash.message)}
</div>
</g:if>
<div class="page-header">
<h1>Tags</h1>
</div>
Expand Down

0 comments on commit fb0a97e

Please sign in to comment.