mirror of https://github.com/sipwise/repoapi.git
* we need to use reference ( docker API it doesn't support tag name ) * fix tag date (value in the first occurrence not last) Change-Id: I2fa2f7bedaca4cdeeb3a3a2d4a3f4a661d15fad1changes/76/14076/6
parent
731dd69df0
commit
629fde1c13
File diff suppressed because one or more lines are too long
@ -0,0 +1,22 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.9 on 2017-06-26 17:22
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('release_dashboard', '0002_dockerimage'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunSQL(
|
||||
[("DELETE FROM release_dashboard_dockertag;", None)]),
|
||||
migrations.AddField(
|
||||
model_name='dockertag',
|
||||
name='reference',
|
||||
field=models.CharField(max_length=150, unique=True),
|
||||
),
|
||||
]
|
@ -0,0 +1,34 @@
|
||||
$('button.delete').click(function(e){
|
||||
// don't send the form
|
||||
e.preventDefault();
|
||||
var button = $(this);
|
||||
var pk = button.attr('pk');
|
||||
var span = $('span#' + pk);
|
||||
var div = $('div.list-group-item#row_'+ pk);
|
||||
|
||||
function successFunc(data, status) {
|
||||
span.html('Done');
|
||||
div.addClass("hidden");
|
||||
}
|
||||
|
||||
function errorFunc(jqXHR, status, error) {
|
||||
span.html(error);
|
||||
button.removeAttr("disabled");
|
||||
}
|
||||
|
||||
if(confirm('Are you sure?')) {
|
||||
$.ajax({
|
||||
url: '/docker/tag/' + pk + '/',
|
||||
type: 'DELETE',
|
||||
success: successFunc,
|
||||
error: errorFunc,
|
||||
beforeSend: csrftokenFunc
|
||||
});
|
||||
|
||||
//deactivate button
|
||||
button.attr("disabled", "disabled");
|
||||
span.html('processing');
|
||||
span.show();
|
||||
}
|
||||
|
||||
});
|
@ -0,0 +1,14 @@
|
||||
{% extends "release_dashboard/base.html" %}
|
||||
{% load staticfiles %}
|
||||
{% block title %}Build docker images per project{% endblock %}
|
||||
{% block navlist %}
|
||||
<li><a href="{% url 'release_dashboard:index'%}">Release Dashboard</a></li>
|
||||
<li><a href="{% url 'release_dashboard:docker_images'%}">Docker Images</a></li>
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
{% include "release_dashboard/docker_image_content.html" %}
|
||||
{% endblock %}
|
||||
{% block extrajs %}
|
||||
<script src="{% static "release_dashboard/js/csrf.js" %}"></script>
|
||||
<script src="{% static "release_dashboard/js/docker_image.js" %}"></script>
|
||||
{% endblock %}
|
@ -0,0 +1,61 @@
|
||||
<div class="container">
|
||||
<form method="POST" class="form-inline">{% csrf_token %}
|
||||
<div class="panel panel-default">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">Data</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<table class="table table-condensed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Image</th>
|
||||
<th>Project</th>
|
||||
<th>Tags</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for i in images %}
|
||||
<tr>
|
||||
<th><label>
|
||||
<a href="{% url 'release_dashboard:docker_image_tag' i.project.name i.name%}">
|
||||
{{ i.name }}
|
||||
</a>
|
||||
</label></th>
|
||||
<td>
|
||||
<a href="{% url 'release_dashboard:docker_project_images' i.project.name%}">
|
||||
{{ i.project.name }}
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
<div class="list-group">
|
||||
{% for tag in i.dockertag_set.all %}
|
||||
<div id="row_{{tag.pk}}" class="list-group-item">
|
||||
<a href="{{URL_BASE}}{{i.name}}/manifests/{{tag.name}}">
|
||||
{% if tag.name|length > 10 %}
|
||||
<span class="btn btn-warning">
|
||||
{% else %}
|
||||
<span class="btn btn-success">
|
||||
{% endif %}
|
||||
{{ tag.name|truncatechars:10 }}
|
||||
</span>
|
||||
</a>
|
||||
<div class="pull-right">
|
||||
<button pk="{{tag.pk}}" class="delete btn btn-danger">Delete</button>
|
||||
<span id="{{tag.pk}}" class="hidden">Done</span>
|
||||
</div>
|
||||
<span class="text-info">
|
||||
{{tag.date|date:"DATETIME_FORMAT"}}
|
||||
</span>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
@ -0,0 +1,41 @@
|
||||
# Copyright (C) 2017 The Sipwise Team - http://sipwise.com
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by the Free
|
||||
# Software Foundation, either version 3 of the License, or (at your option)
|
||||
# any later version.
|
||||
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
# more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License along
|
||||
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.conf import settings
|
||||
from rest_framework import status
|
||||
from rest_framework.test import APITestCase
|
||||
from release_dashboard import models
|
||||
from mock import patch
|
||||
|
||||
|
||||
class TestDockerRest(APITestCase):
|
||||
fixtures = ['test_model_fixtures', ]
|
||||
|
||||
@patch('release_dashboard.utils.docker.delete_docker_info')
|
||||
def test_deletion(self, ddi):
|
||||
image_name = 'ngcp-panel-tests-rest-api-jessie'
|
||||
tag = models.DockerTag.objects.get(
|
||||
name='latest',
|
||||
image__name=image_name)
|
||||
response = self.client.delete(
|
||||
reverse('dockertag-detail', args=[tag.pk]), format='json')
|
||||
self.assertEqual(response.status_code, status.HTTP_202_ACCEPTED)
|
||||
self.assertFalse(
|
||||
models.DockerTag.objects.filter(
|
||||
name='latest',
|
||||
image__name=image_name).exists())
|
||||
ddi.assert_called_once_with(settings.DOCKER_REGISTRY_URL.format(
|
||||
'%s/manifests/%s' % (image_name, tag.reference)))
|
Loading…
Reference in new issue