feat(ui): add the ability to pull an image from a private registry (#47)

pull/49/head
Anthony Lapenna 9 years ago committed by GitHub
parent 06f54e300c
commit d2fb2cb863

@ -4,7 +4,6 @@
<i class="fa fa-refresh" aria-hidden="true"></i> <i class="fa fa-refresh" aria-hidden="true"></i>
</a> </a>
</rd-header-title> </rd-header-title>
<rd-header-content>Images</rd-header-content> <rd-header-content>Images</rd-header-content>
</rd-header> </rd-header>
@ -15,14 +14,18 @@
</rd-widget-header> </rd-widget-header>
<rd-widget-body> <rd-widget-body>
<form class="form-horizontal"> <form class="form-horizontal">
<!-- name-input --> <!-- name-and-registry-inputs -->
<div class="form-group"> <div class="form-group">
<label for="image_name" class="col-sm-1 control-label text-left">Name</label> <label for="image_name" class="col-sm-1 control-label text-left">Name</label>
<div class="col-sm-11"> <div class="col-sm-7">
<input type="text" class="form-control" ng-model="config.Image" id="image_name" placeholder="e.g. ubuntu:trusty"> <input type="text" class="form-control" ng-model="config.Image" id="image_name" placeholder="e.g. ubuntu:trusty">
</div> </div>
<label for="image_registry" class="col-sm-1 control-label text-left">Registry</label>
<div class="col-sm-3">
<input type="text" class="form-control" ng-model="config.Registry" id="image_registry" placeholder="leave empty to use DockerHub">
</div>
</div> </div>
<!-- !name-input --> <!-- !name-and-registry-inputs -->
<!-- tag-note --> <!-- tag-note -->
<div class="form-group"> <div class="form-group">
<div class="col-sm-12"> <div class="col-sm-12">

@ -8,7 +8,8 @@ function ($scope, $state, Image, Messages) {
$scope.state.selectedItemCount = 0; $scope.state.selectedItemCount = 0;
$scope.config = { $scope.config = {
Image: '' Image: '',
Registry: '',
}; };
$scope.order = function(sortType) { $scope.order = function(sortType) {
@ -35,10 +36,14 @@ function ($scope, $state, Image, Messages) {
} }
}; };
function createImageConfig(imageName) { function createImageConfig(imageName, registry) {
var imageNameAndTag = imageName.split(':'); var imageNameAndTag = imageName.split(':');
var image = imageNameAndTag[0];
if (registry) {
image = registry + '/' + imageNameAndTag[0];
}
var imageConfig = { var imageConfig = {
fromImage: imageNameAndTag[0], fromImage: image,
tag: imageNameAndTag[1] ? imageNameAndTag[1] : 'latest' tag: imageNameAndTag[1] ? imageNameAndTag[1] : 'latest'
}; };
return imageConfig; return imageConfig;
@ -47,7 +52,8 @@ function ($scope, $state, Image, Messages) {
$scope.pullImage = function() { $scope.pullImage = function() {
$('#pullImageSpinner').show(); $('#pullImageSpinner').show();
var image = _.toLower($scope.config.Image); var image = _.toLower($scope.config.Image);
var imageConfig = createImageConfig(image); var registry = _.toLower($scope.config.Registry);
var imageConfig = createImageConfig(image, registry);
Image.create(imageConfig, function (data) { Image.create(imageConfig, function (data) {
var err = data.length > 0 && data[data.length - 1].hasOwnProperty('error'); var err = data.length > 0 && data[data.length - 1].hasOwnProperty('error');
if (err) { if (err) {

Loading…
Cancel
Save