Skip to content

Commit de7a63c

Browse files
committed
Merge branch 'devel'
2 parents d6d3359 + d88a28f commit de7a63c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1945
-277
lines changed

.mvn/wrapper/maven-wrapper.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip
1+
distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.2/apache-maven-3.5.2-bin.zip

.travis.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,7 @@ language: java
22
jdk:
33
- oraclejdk8
44
sudo: false
5-
script: ./mvnw clean verify
5+
script: ./mvnw clean verify cobertura:cobertura-integration-test
6+
7+
after_success:
8+
- bash <(curl -s https://codecov.io/bash)

README.md

+15-89
Original file line numberDiff line numberDiff line change
@@ -1,103 +1,29 @@
11
# Boxitory
22

3-
is repository for Vagrant's Virtual Machine boxes, which can manage box versions and provides *Vagrant* compatible http interface.
3+
is repository for Vagrant's Virtual Machine boxes, which can manage box versions and provides *Vagrant* compatible http interface. Boxes are stored on local filesystem.
4+
5+
Download [Latest release](https://github.com/sparkoo/boxitory/releases/latest)
6+
7+
For more info how it works, how to configure, ... [See Wiki](https://github.com/sparkoo/boxitory/wiki)
48

59
## Build & run
610

7-
`./mvnw install && java -jar target/boxitory-{version}.jar`
11+
```
12+
$ ./mvnw install && java -jar target/boxitory-{version}.jar
13+
```
14+
or
15+
```
16+
$ ./mvnw spring-boot:run
17+
```
818

919
By default, http server will start on port *8083*.
1020

1121
#### Build status (travis-ci)
1222

13-
devel [![Build Status](https://travis-ci.org/sparkoo/boxitory.svg?branch=devel)](https://travis-ci.org/sparkoo/boxitory)
14-
15-
master: [![Build Status](https://travis-ci.org/sparkoo/boxitory.svg?branch=master)](https://travis-ci.org/sparkoo/boxitory)
16-
17-
## How it works
18-
19-
*Boxitory* currently implements just filesystem box provider. That requires strict folder structure.
23+
devel [![Build Status](https://travis-ci.org/sparkoo/boxitory.svg?branch=devel)](https://travis-ci.org/sparkoo/boxitory)
24+
[![codecov](https://codecov.io/gh/sparkoo/boxitory/branch/devel/graph/badge.svg)](https://codecov.io/gh/sparkoo/boxitory)
2025

21-
### Box files on filesystem
2226

23-
There must be one home folder for all boxes with subfolders for each box type. Individial box versions must be named `{name}_{version}_{provider}.box`.
24-
25-
See example below:
26-
```
27-
$ tree test_repository/
28-
test_repository/
29-
├── f25
30-
│   ├── f25_1_virtualbox.box
31-
│   └── f25_2_virtualbox.box
32-
├── f26
33-
│   ├── f26_1_virtualbox.box
34-
│   ├── f26_2_virtualbox.box
35-
│   └── f26_3_virtualbox.box
36-
```
37-
38-
### Http interface
39-
40-
Server starts at port *8083* and boxes can be requested on `http://hostname:port/box_name` for example:
41-
```
42-
$ curl http://localhost:8083/f26
43-
{
44-
"name": "f26",
45-
"description": "f26",
46-
"versions": [
47-
{
48-
"version": "1",
49-
"providers": [
50-
{
51-
"url": "sftp://my_box_server:/tmp/test_repository/f26/f26_1_virtualbox.box",
52-
"name": "virtualbox"
53-
}
54-
]
55-
},
56-
{
57-
"version": "2",
58-
"providers": [
59-
{
60-
"url": "sftp://my_box_server:/tmp/test_repository/f26/f26_2_virtualbox.box",
61-
"name": "virtualbox"
62-
}
63-
]
64-
},
65-
]
66-
}
67-
```
27+
master: [![Build Status](https://travis-ci.org/sparkoo/boxitory.svg?branch=master)](https://travis-ci.org/sparkoo/boxitory)
6828

69-
## Configuration
7029

71-
### Options
72-
* `box.home`
73-
* path where to find boxes
74-
* in example above, it will be set to `/tmp/test_repository`
75-
* **default value**: `.`
76-
* `box.prefix`
77-
* prefix for the output json, that is prepend before absolute local path of the box
78-
* do define for example protocol or server, where boxes are placed
79-
* e.g.: `sftp://my_box_server:`
80-
* **default value**: *empty*
81-
* `box.sort_desc`
82-
* boolean value `true|false`
83-
* when default or `false`, boxes are sorted by version in ascending order
84-
* when `true`, boxes are sorted by version in descending order
85-
* default value: `false`
86-
* `box.checksum`
87-
* string value: `disabled|md5|sha1|sha256`
88-
* default value: `disabled`
89-
* when default or `disabled` boxes output json not contains properties `checksumType` and `checksum`
90-
* when `md5|sha1|sha256` boxes output json contains properties `checksumType` and `checksum` with coresponding values
91-
### Advanced Options
92-
* `box.checksum_buffer_size`
93-
* Box file is loaded to this buffer to calculate box checksums
94-
* default value: `1024`
95-
96-
### How to configuration
97-
Configuration can be provided by `application.properties` file on classpath
98-
```
99-
# application.properties
100-
box.home=/tmp/test_repository
101-
box.prefix=sftp://my_box_server:
102-
```
103-
or as command line arguments `java -jar -Dbox.home=/tmp/test_repository target/boxsitory-${version}.jar`

application.properties_template

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
box.home=/custom/test/repository/path
22
box.host_prefix=sftp://localhost:
33
server.port=8083
4-
box.checksum=disabled
4+
55
box.sort_desc=false
6+
7+
box.checksum=md5
8+
box.checksum_buffer_size=1024
9+
box.checksum_persist=true

pom.xml

+66-8
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,38 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
34
<modelVersion>4.0.0</modelVersion>
45

56
<groupId>cz.sparko.boxitory</groupId>
67
<artifactId>boxitory</artifactId>
7-
<version>1.2.0</version>
8+
<version>1.2.1-SNAPSHOT</version>
89
<packaging>jar</packaging>
910

1011
<name>boxitory</name>
11-
<description>Demo project for Spring Boot</description>
12+
<description>Vagrant box repository</description>
13+
<url>https://github.com/sparkoo/boxitory</url>
14+
<developers>
15+
<developer>
16+
<name>sparkoo</name>
17+
<url>https://github.com/sparkoo</url>
18+
</developer>
19+
</developers>
20+
<contributors>
21+
<contributor>
22+
<name>D3ryk</name>
23+
<url>https://github.com/D3ryk</url>
24+
</contributor>
25+
</contributors>
26+
<organization>
27+
<name>sparkoo</name>
28+
<url>https://github.com/sparkoo</url>
29+
</organization>
1230

1331
<parent>
1432
<groupId>org.springframework.boot</groupId>
1533
<artifactId>spring-boot-starter-parent</artifactId>
1634
<version>1.5.3.RELEASE</version>
17-
<relativePath /> <!-- lookup parent from repository -->
35+
<relativePath/> <!-- lookup parent from repository -->
1836
</parent>
1937

2038
<issueManagement>
@@ -34,8 +52,8 @@
3452
<url>https://github.com/sparkoo/boxitory</url>
3553
<connection>scm:git:git://github.com/sparkoo/boxitory.git</connection>
3654
<developerConnection>scm:git:[email protected]:sparkoo/boxitory.git</developerConnection>
37-
<tag>v1.2.0</tag>
38-
</scm>
55+
<tag>HEAD</tag>
56+
</scm>
3957

4058
<properties>
4159
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -94,8 +112,48 @@
94112
<artifactId>maven-release-plugin</artifactId>
95113
<version>2.5.3</version>
96114
</plugin>
115+
<plugin>
116+
<groupId>org.codehaus.mojo</groupId>
117+
<artifactId>cobertura-maven-plugin</artifactId>
118+
<version>2.7</version>
119+
<configuration>
120+
<formats>
121+
<format>html</format>
122+
<format>xml</format>
123+
</formats>
124+
<instrumentation>
125+
<ignoreTrivial>true</ignoreTrivial>
126+
</instrumentation>
127+
<check/>
128+
</configuration>
129+
</plugin>
130+
<plugin>
131+
<groupId>org.apache.maven.plugins</groupId>
132+
<artifactId>maven-surefire-plugin</artifactId>
133+
<version>2.20</version>
134+
<configuration>
135+
<excludedGroups>e2e</excludedGroups>
136+
</configuration>
137+
</plugin>
138+
<plugin>
139+
<groupId>org.apache.maven.plugins</groupId>
140+
<artifactId>maven-failsafe-plugin</artifactId>
141+
<version>2.18.1</version>
142+
<configuration>
143+
<groups>e2e</groups>
144+
<includes>
145+
<include>**/*Test.java</include>
146+
</includes>
147+
</configuration>
148+
<executions>
149+
<execution>
150+
<goals>
151+
<goal>integration-test</goal>
152+
<goal>verify</goal>
153+
</goals>
154+
</execution>
155+
</executions>
156+
</plugin>
97157
</plugins>
98158
</build>
99-
100-
101159
</project>

src/main/java/cz/sparko/boxitory/App.java

+32-4
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,13 @@
33
import cz.sparko.boxitory.conf.AppProperties;
44
import cz.sparko.boxitory.factory.HashServiceFactory;
55
import cz.sparko.boxitory.service.BoxRepository;
6-
import cz.sparko.boxitory.service.FilesystemBoxRepository;
6+
import cz.sparko.boxitory.service.DescriptionProvider;
7+
import cz.sparko.boxitory.service.filesystem.FilesystemBoxRepository;
8+
import cz.sparko.boxitory.service.filesystem.FilesystemDescriptionProvider;
9+
import cz.sparko.boxitory.service.filesystem.FilesystemHashStore;
710
import cz.sparko.boxitory.service.HashService;
11+
import cz.sparko.boxitory.service.HashStore;
12+
import cz.sparko.boxitory.service.noop.NoopHashStore;
813
import org.springframework.beans.factory.annotation.Autowired;
914
import org.springframework.boot.SpringApplication;
1015
import org.springframework.boot.autoconfigure.SpringBootApplication;
@@ -21,8 +26,31 @@ public static void main(String[] args) {
2126

2227
@Bean
2328
@Autowired
24-
public BoxRepository boxRepository(AppProperties appProperties) throws NoSuchAlgorithmException {
25-
HashService hashService = HashServiceFactory.createHashService(appProperties);
26-
return new FilesystemBoxRepository(appProperties, hashService);
29+
public BoxRepository boxRepository(AppProperties appProperties,
30+
HashService hashService,
31+
DescriptionProvider descriptionProvider) {
32+
return new FilesystemBoxRepository(appProperties, hashService, descriptionProvider);
33+
}
34+
35+
@Bean
36+
@Autowired
37+
public DescriptionProvider descriptionProvider(AppProperties appProperties) {
38+
return new FilesystemDescriptionProvider(appProperties.getHome());
39+
}
40+
41+
@Bean
42+
@Autowired
43+
public HashService hashService(AppProperties appProperties, HashStore hashStore) throws NoSuchAlgorithmException {
44+
return HashServiceFactory.createHashService(appProperties, hashStore);
45+
}
46+
47+
@Bean
48+
@Autowired
49+
public HashStore hashStore(AppProperties appProperties) {
50+
if (appProperties.isChecksum_persist()) {
51+
return new FilesystemHashStore();
52+
} else {
53+
return new NoopHashStore();
54+
}
2755
}
2856
}

src/main/java/cz/sparko/boxitory/conf/AppProperties.java

+14-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package cz.sparko.boxitory.conf;
22

3+
import cz.sparko.boxitory.service.HashService.HashAlgorithm;
34
import org.springframework.boot.context.properties.ConfigurationProperties;
45
import org.springframework.context.annotation.Configuration;
56

@@ -8,8 +9,10 @@
89
public class AppProperties {
910
private String home = ".";
1011
private String host_prefix = "";
11-
private String checksum = "disabled";
1212
private boolean sort_desc = false;
13+
14+
private HashAlgorithm checksum = HashAlgorithm.DISABLED;
15+
private boolean checksum_persist = true;
1316
private int checksum_buffer_size = 1024;
1417

1518
public String getHome() {
@@ -24,14 +27,18 @@ public boolean isSort_desc() {
2427
return sort_desc;
2528
}
2629

27-
public String getChecksum() {
30+
public HashAlgorithm getChecksum() {
2831
return checksum;
2932
}
3033

3134
public int getChecksum_buffer_size() {
3235
return checksum_buffer_size;
3336
}
3437

38+
public boolean isChecksum_persist() {
39+
return checksum_persist;
40+
}
41+
3542
public void setSort_desc(boolean sort_desc) {
3643
this.sort_desc = sort_desc;
3744
}
@@ -44,11 +51,15 @@ public void setHost_prefix(String host_prefix) {
4451
this.host_prefix = host_prefix;
4552
}
4653

47-
public void setChecksum(String checksum) {
54+
public void setChecksum(HashAlgorithm checksum) {
4855
this.checksum = checksum;
4956
}
5057

5158
public void setChecksum_buffer_size(int checksum_buffer_size) {
5259
this.checksum_buffer_size = checksum_buffer_size;
5360
}
61+
62+
public void setChecksum_persist(boolean checksum_persist) {
63+
this.checksum_persist = checksum_persist;
64+
}
5465
}
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
package cz.sparko.boxitory.conf;
22

33
import org.springframework.http.HttpStatus;
4-
import org.springframework.web.bind.annotation.ResponseStatus;
4+
import org.springframework.web.client.HttpClientErrorException;
55

6-
@ResponseStatus(value = HttpStatus.NOT_FOUND)
7-
public class NotFoundException extends RuntimeException {
6+
public class NotFoundException extends HttpClientErrorException {
87
public NotFoundException(String message) {
9-
super(message);
8+
super(HttpStatus.NOT_FOUND, message);
9+
}
10+
11+
public static NotFoundException boxNotFound(String boxName) {
12+
return new NotFoundException("box [" + boxName + "] does not exist");
1013
}
1114
}

0 commit comments

Comments
 (0)