Skip to content

Commit

Permalink
Merge pull request #18 from schemaspy/master
Browse files Browse the repository at this point in the history
Merge with master
  • Loading branch information
wkasa committed Jun 9, 2017
2 parents 42657f9 + 03a647d commit 8e1213a
Show file tree
Hide file tree
Showing 42 changed files with 1,295 additions and 312 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -7,3 +7,5 @@ schemaspy.iml
/bin/
schemaspy.properties
*.iml
!ext-lib
ext-lib/**/*.jar
11 changes: 9 additions & 2 deletions README.md
Expand Up @@ -2,8 +2,8 @@

[![Build Status](https://travis-ci.org/schemaspy/schemaspy.svg?branch=master)](https://travis-ci.org/schemaspy/schemaspy)
[![Documentation Status](https://readthedocs.org/projects/schemaspy/badge/?version=latest)](http://schemaspy.readthedocs.io/en/latest/?badge=latest)
[![Quality Gate](https://sonarqube.com/api/badges/gate?key=org.schemaspy%3Aschemaspy)](https://sonarqube.com/dashboard/index?id=org.schemaspy%3Aschemaspy)
[![Quality Gate](https://sonarqube.com/api/badges/measure?key=org.schemaspy%3Aschemaspy&metric=coverage)](https://sonarqube.com/dashboard/index?id=org.schemaspy%3Aschemaspy)
[![Quality Gate](https://sonarqube.com/api/badges/gate?key=org.schemaspy%3Aschemaspy)](https://sonarcloud.io/dashboard?id=org.schemaspy%3Aschemaspy)
[![Quality Gate](https://sonarqube.com/api/badges/measure?key=org.schemaspy%3Aschemaspy&metric=coverage)](https://sonarcloud.io/dashboard?id=org.schemaspy%3Aschemaspy)
[![Gitter](https://badges.gitter.im/schemaspy/schemaspy.svg)](https://gitter.im/schemaspy/schemaspy?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)

> Please support a project by simply putting a Github star.
Expand Down Expand Up @@ -68,3 +68,10 @@ Are very welcome! And remember, contribution is not only PRs and code, but any h
SchemaSpy is maintained by [Rafal Kasa](malito:rafalkasa@gmail.com) with SchemaSpy community support please contact with me if you have some question or proposition.
* https://github.com/rafalkasa

## Team Tools

[![alt tag](http://pylonsproject.org/img/logo-jetbrains.png)](https://www.jetbrains.com/)

SchemaSpy Team would like inform that JetBrains is helping by provided IDE to develop the application. Thanks to its support program for an Open Source projects !


13 changes: 13 additions & 0 deletions TESTING.md
@@ -0,0 +1,13 @@
# Unit

# Integration Testing

## Test-containers
* Requires docker

### Oracle-XE
Since oracle jdbc driver is proprietary you need to fetch it on your own.

Put ojdbc[version].jar in ext-lib and it will be discovered.
The OracleIT test will check for ojdbc* in ext-lib and also check
if docker "works" if one of them fails the tests will be ignored.
37 changes: 37 additions & 0 deletions docker/release/Dockerfile
@@ -0,0 +1,37 @@
FROM openjdk:8-jre-alpine

ENV LC_ALL=C

ADD entrypoint.sh /

RUN set -o pipefail && \
adduser java -h / -D && \
apk update && apk add --no-cache curl unzip jq graphviz fontconfig && \
cd /tmp && \
curl https://www.fontsquirrel.com/fonts/download/open-sans -J -O && \
unzip open-sans.zip -d /usr/share/fonts && \
rm open-sans.zip && \
cd / && \
fc-cache -fv && \
curl -s https://api.github.com/repos/schemaspy/schemaspy/releases/latest | jq -r ".assets[] | select(.name | test(\"jar\")) | .browser_download_url" | xargs curl -JOL && \
echo "export MAIN_CLASS=$(unzip -p schemaspy*.jar META-INF/MANIFEST.MF | grep Main-Class | awk -F ': ' '{sub(/\r/,"",$2);print $2}')" > .env &&\
mkdir /drivers && \
mkdir /output && \
mkdir /config && \
chown -R java /schema* && \
chown -R java /drivers && \
chown -R java /output && \
chown -R java /config && \
chmod ugo+x entrypoint.sh && \
apk del curl unzip jq && \
rm -rf /var/cache/*



USER java

WORKDIR /

VOLUME /drivers /output /config

ENTRYPOINT ["/entrypoint.sh"]
3 changes: 3 additions & 0 deletions docker/release/entrypoint.sh
@@ -0,0 +1,3 @@
#!/bin/sh
source /.env
exec java -cp *:/drivers/* $MAIN_CLASS -o /output "$@"
36 changes: 36 additions & 0 deletions docker/release/readme.md
@@ -0,0 +1,36 @@
## Docker image for SchemaSpy

### Build info

We currently build and publish release image and snapshot images.
This are distinguished by tag.

Alpine base with:
* openjdk8-jre
* OpenSans font
* graphviz

### Usage
Currently the build contains 0 driver.

It exposes 3 volumes that can be mounted

/driver /output /config

The container will load all libraries drivers, it will have output set to /output

Container will exit when finished.

Example:
`docker run -v "$PWD/drivers:/driver" -v "$PWD/output:/output" schemaspy:[tag] -t mysql -db [database] -u [user] -p [password] -host [host] -port [port]`

The example above assumes that the mysql jdbc driver is located in $PWD/drivers
and output will be written to $PWD/output.

### Caveats
If you are new to docker localhost is inside the container and not the dockerhost.
-net=host probably doesn't work with docker toolbox or docker for (mac|windows).

## Issues
Create an issue in the [github project](https://github.com/schemaspy/schemaspy/issues)

34 changes: 34 additions & 0 deletions docker/snapshot/Dockerfile
@@ -0,0 +1,34 @@
FROM openjdk:8-jre-alpine

ENV LC_ALL=C

RUN adduser java -h / -D && \
set -x && \
apk add --no-cache curl git unzip graphviz fontconfig openjdk8="$JAVA_ALPINE_VERSION" && \
mkdir -p /opt/build && cd /opt/build && \
curl https://www.fontsquirrel.com/fonts/download/open-sans -J -O && \
unzip open-sans.zip -d /usr/share/fonts && \
fc-cache -fv && \
git clone https://github.com/schemaspy/schemaspy.git && \
cd schemaspy && \
./mvnw package && \
cp target/schemaspy*.jar / && \
cd / && \
rm -rf /opt/build && \
rm -rf ~/.m2 && \
apk del curl git unzip openjdk8 && \
mkdir /drivers && \
mkdir /output && \
mkdir /config && \
chown -R java /schema* && \
chown -R java /drivers && \
chown -R java /output && \
chown -R java /config

USER java

WORKDIR /

VOLUME /drivers /output /config

ENTRYPOINT ["java","-cp","*:/drivers/*","org.springframework.boot.loader.JarLauncher", "-o", "/output"]
Empty file added ext-lib/put_driver_here
Empty file.
17 changes: 17 additions & 0 deletions pom.xml
Expand Up @@ -62,6 +62,12 @@
<email>rafalkasa@gmail.com</email>
</developer>
</developers>
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencyManagement>
<dependencies>
<dependency>
Expand Down Expand Up @@ -178,6 +184,17 @@
<artifactId>h2</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.beust</groupId>
<artifactId>jcommander</artifactId>
<version>1.69</version>
</dependency>
<dependency>
<groupId>com.github.npetzall.testcontainers-java</groupId>
<artifactId>oracle-xe</artifactId>
<version>1.2.2-SNAPSHOT-0.3</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<resources>
Expand Down
78 changes: 38 additions & 40 deletions src/main/java/org/schemaspy/Config.java
Expand Up @@ -18,13 +18,16 @@
*/
package org.schemaspy;

import org.schemaspy.cli.CommandLineArgumentParser;
import org.schemaspy.cli.CommandLineArguments;
import org.schemaspy.model.InvalidConfigurationException;
import org.schemaspy.util.DbSpecificConfig;
import org.schemaspy.util.Dot;
import org.schemaspy.util.PasswordReader;
import org.schemaspy.view.DefaultSqlFormatter;
import org.schemaspy.view.SqlFormatter;
import org.springframework.util.FileCopyUtils;
import org.springframework.util.StringUtils;

import java.beans.BeanInfo;
import java.beans.IntrospectionException;
Expand Down Expand Up @@ -55,7 +58,6 @@ public class Config {
private Map<String, String> originalDbSpecificOptions;
private boolean helpRequired;
private boolean dbHelpRequired;
private File outputDir;
private File graphvizDir;
private String dbType;
private String catalog;
Expand Down Expand Up @@ -191,25 +193,6 @@ public boolean isImpliedConstraintsEnabled() {
return includeImpliedConstraints;
}

public void setOutputDir(String outputDirName) {
if (outputDirName.endsWith("\""))
outputDirName = outputDirName.substring(0, outputDirName.length() - 1);

setOutputDir(new File(outputDirName));
}

public void setOutputDir(File outputDir) {
this.outputDir = outputDir;
}

public File getOutputDir() {
if (outputDir == null) {
setOutputDir(pullRequiredParam("-o"));
}

return outputDir;
}

/**
* Set the path to Graphviz so we can find dot to generate ER diagrams
*
Expand Down Expand Up @@ -285,19 +268,15 @@ public String getTemplateDirectory() {
return templateDirectory;
}

public boolean isJarFile() {
return true;
//FIXME what is this good for?
// if (jarFile == null) {
// jarFile = new File(getClass().getProtectionDomain().getCodeSource().getLocation().getPath());
// }
// return jarFile.isFile();
}

public void setDbType(String dbType) {
this.dbType = dbType;
}

/**
* @deprecated use {@link CommandLineArguments#getDatabaseType()}
* @return
*/
@Deprecated
public String getDbType() {
if (dbType == null) {
dbType = pullParam("-t");
Expand All @@ -312,6 +291,11 @@ public void setDb(String db) {
this.db = db;
}

/**
* @deprecated use {@link CommandLineArguments#getDatabaseName()}
* @return
*/
@Deprecated
public String getDb() {
if (db == null)
db = pullParam("-db");
Expand All @@ -322,6 +306,11 @@ public void setCatalog(String catalog) {
this.catalog = catalog;
}

/**
* @deprecated use {@link CommandLineArguments#getCatalog()}
* @return
*/
@Deprecated
public String getCatalog() {
if (catalog == null)
catalog = pullParam("-cat");
Expand All @@ -332,6 +321,11 @@ public void setSchema(String schema) {
this.schema = schema;
}

/**
* @deprecated use {@link CommandLineArguments#getSchema()}
* @return
*/
@Deprecated
public String getSchema() {
if (schema == null)
schema = pullParam("-s");
Expand Down Expand Up @@ -362,17 +356,17 @@ public String getHost() {
return host;
}

public void setPort(Integer port) {
this.port = port;
}

public Integer getPort() {
if (port == null)
try {
port = Integer.valueOf(pullParam("-port"));
} catch (Exception notSpecified) {
logger.log(Level.WARNING, notSpecified.getMessage(), notSpecified);
if (port == null) {
String portAsString = pullParam("-port");
if (StringUtils.hasText(portAsString)) {
try {
port = Integer.valueOf(portAsString);
} catch (NumberFormatException notSpecified) {
logger.log(Level.WARNING, notSpecified.getMessage(), notSpecified);
}
}
}
return port;
}

Expand Down Expand Up @@ -1745,6 +1739,12 @@ public static Set<String> getBuiltInDatabaseTypes(String loadedFromJar) {
return databaseTypes;
}

/**
* @deprecated use {@link CommandLineArgumentParser#printUsage()} resp. {@link CommandLineArgumentParser#printDatabaseTypesHelp()}
* @param errorMessage
* @param detailedDb
*/
@Deprecated
protected void dumpUsage(String errorMessage, boolean detailedDb) {
if (errorMessage != null) {
System.out.flush();
Expand Down Expand Up @@ -1982,8 +1982,6 @@ public List<String> asList() throws IOException {
params.add(String.valueOf(getMaxDbThreads()));
params.add("-maxdet");
params.add(String.valueOf(getMaxDetailedTables()));
params.add("-o");
params.add(getOutputDir().toString());

return params;
}
Expand Down

0 comments on commit 8e1213a

Please sign in to comment.