Skip to content
This repository was archived by the owner on Jan 17, 2023. It is now read-only.

Commit f0a9987

Browse files
author
Alex Collins
committed
Merge pull request #71 from atc-/0.9.0
0.9.0
2 parents 8a11d41 + d22742e commit f0a9987

29 files changed

+440
-54
lines changed

application.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
#Wed Jul 09 18:55:10 BST 2014
33
app.grails.version=2.4.2
44
app.name=docker-registry-ui
5-
app.version=0.8.1
5+
app.version=0.9.0

grails-app/conf/BootStrap.groovy

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import docker.registry.web.Registry
22
import docker.registry.web.User
3-
import groovyx.net.http.URIBuilder
43

54
class BootStrap {
65

@@ -16,24 +15,27 @@ class BootStrap {
1615
System.getenv().each { key, urlStr ->
1716
if (key.matches("REG(\\d)")) {
1817
log.info("Found registry $urlStr. Creating...")
19-
def m = urlStr =~ /.*(v\d).*/
18+
def reg = Registry.fromUrl(urlStr)
2019

21-
if (m.matches()) {
22-
def reg = new Registry()
23-
reg.url = urlStr.replaceAll("/(v\\d)/", "") // remove API version
24-
reg.apiVersion = m.group(1) // extracts e.g. v1 from url
25-
reg.save()
20+
if (reg) {
21+
if (Registry.findByHostAndApiVersion(reg.host, reg.apiVersion)) {
22+
log.info("Not creating registry ${urlStr} as it already exists")
23+
} else {
24+
log.info("Registry ${reg} doesn't exist; saving")
25+
reg.save()
26+
}
2627

2728
if (!reg.ping()) {
2829
log.warn("Registry '${reg.toUrl()}' ping failed! Check it's up!")
2930
}
3031

3132
} else {
32-
log.error("Couldn't parse the API version from $regUrl")
33+
log.error("Couldn't parse valid registry URL from $urlStr")
3334
}
3435
}
3536
}
3637
}
38+
3739
def destroy = {
3840
}
3941
}

grails-app/conf/BuildConfig.groovy

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ grails.project.dependency.resolution = {
7070
compile ":jquery-ui:1.10.3"
7171
compile ":jquery-datatables:1.7.5"
7272
compile ":spring-security-core:2.0-RC3"
73-
compile ":dwr:0.1"
7473

7574
// plugins needed at runtime but not for compilation
7675
runtime ":hibernate4:4.3.5.3"

grails-app/conf/DwrConfigBootStrap.groovy

Lines changed: 0 additions & 16 deletions
This file was deleted.

grails-app/domain/docker/registry/web/Registry.groovy

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,30 @@
11
package docker.registry.web
22

3+
import groovyx.net.http.HTTPBuilder
4+
35
class Registry {
4-
String url
5-
String apiVersion
6+
String host = "localhost"
7+
int port
8+
String apiVersion = "v1"
9+
String username
10+
String password
611

712
def repositoryService
813

914
static constraints = {
15+
username nullable: true
16+
password nullable: true
1017
}
1118

12-
static transients = ['toUrl', 'repositories', 'ping']
19+
static transients = ['toUrl', 'repositories', 'ping', 'fromUrl']
1320

1421
def toUrl() {
15-
return "${this.url}/${this.apiVersion}"
22+
def urlString = "http://${this.host}:${this.port}/${this.apiVersion}"
23+
if (username) {
24+
if (password) urlString = urlString.replace("://", "://$username:$password@")
25+
else urlString = urlString.replace("://", "://$username@")
26+
}
27+
urlString
1628
}
1729

1830
def getRepositories() {
@@ -23,12 +35,37 @@ class Registry {
2335
repositoryService.ping(this)
2436
}
2537

38+
/**
39+
* Static factory method for creating an instance from a URL.
40+
* @param urlStr a url in the format: http://hostOrIP:OptionalPort/v1/
41+
**/
42+
static def fromUrl(final String urlStr) {
43+
if (urlStr?.endsWith("/v1/")) { //FIXME this won't work for new api versions
44+
def url = urlStr.toURL()
45+
if (url) {
46+
def auth = url.userInfo?.split(":")
47+
return new Registry(
48+
host: url.host,
49+
port: url.port == -1 ? 80 : url.port,
50+
apiVersion: url.path.replaceAll("\\p{Punct}", ""),
51+
username: auth?.length > 0 ? auth[0] : null,
52+
password: auth?.length > 1 ? auth[1] : null
53+
)
54+
}
55+
}
56+
null
57+
}
58+
2659
@Override
2760
public String toString() {
2861
return "Registry{" +
2962
"id=" + id +
30-
", url='" + url + '\'' +
63+
", host='" + host + '\'' +
64+
", port=" + port +
3165
", apiVersion='" + apiVersion + '\'' +
66+
", username='" + username + '\'' +
67+
", password='" + password + '\'' +
68+
", repositoryService=" + repositoryService +
3269
", version=" + version +
3370
'}';
3471
}

grails-app/i18n/messages.properties

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,11 @@ ui.dialog.button.deleteTag=Delete tag
8080
registry.ping.failed=Ping failed\!
8181
registry.ping.succeeded=Ping succeeded
8282
labels.registry.ping=Pingable?
83+
registry.host.label=Hostname
84+
registry.port.label=Port
85+
registry.password.label=Password
86+
registry.username.label=Username
87+
labels.registry.host=Hostname
88+
labels.registry.port=Port
89+
labels.registry.username=Username
90+
labels.registry.password=Password

grails-app/i18n/messages_cs_CZ.properties

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,11 @@ ui.dialog.button.deleteTag=Delete tag
8080
registry.ping.failed=Ping failed\!
8181
registry.ping.succeeded=Ping succeeded
8282
labels.registry.ping=Pingable?
83+
registry.host.label=Hostname
84+
registry.port.label=Port
85+
registry.password.label=Password
86+
registry.username.label=Username
87+
labels.registry.host=Hostname
88+
labels.registry.port=Port
89+
labels.registry.username=Username
90+
labels.registry.password=Password

grails-app/i18n/messages_da.properties

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,12 @@ ui.dialog.button.deleteTag=Delete tag
8080
registry.ping.failed=Ping failed\!
8181
registry.ping.succeeded=Ping succeeded
8282
labels.registry.ping=Pingable?
83+
registry.host.label=Hostname
84+
registry.port.label=Port
85+
registry.password.label=Password
86+
registry.username.label=Username
87+
labels.registry.host=Hostname
88+
labels.registry.port=Port
89+
labels.registry.username=Username
90+
labels.registry.password=Password
8391

grails-app/i18n/messages_de.properties

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,11 @@ ui.dialog.button.deleteTag=Delete tag
8080
registry.ping.failed=Ping failed\!
8181
registry.ping.succeeded=Ping succeeded
8282
labels.registry.ping=Pingable?
83+
registry.host.label=Hostname
84+
registry.port.label=Port
85+
registry.password.label=Password
86+
registry.username.label=Username
87+
labels.registry.host=Hostname
88+
labels.registry.port=Port
89+
labels.registry.username=Username
90+
labels.registry.password=Password

grails-app/i18n/messages_es.properties

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,12 @@ registry.url.label=URL
7979
ui.dialog.button.deleteTag=Delete tag
8080
registry.ping.failed=Ping failed\!
8181
registry.ping.succeeded=Ping succeeded
82-
labels.registry.ping=Pingable?
82+
labels.registry.ping=Pingable?
83+
registry.host.label=Hostname
84+
registry.port.label=Port
85+
registry.password.label=Password
86+
registry.username.label=Username
87+
labels.registry.host=Hostname
88+
labels.registry.port=Port
89+
labels.registry.username=Username
90+
labels.registry.password=Password

0 commit comments

Comments
 (0)