Skip to content

Initial workable commit #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM openjdk:8-jdk-alpine
VOLUME /tmp
EXPOSE 8090
ADD target/*.jar terraform-ui.jar
ENV JAVA_OPTS=""
ENTRYPOINT [ "sh", "-c", "java -jar terraform-ui.jar" ]
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ user interface to run terraform (tf) files.
* Provide the location of directory where files will be placed in global.properties (src/main/resources)
#### Clone the version of terraform-ui you want to run.
```
git clone https://github.com/mohnishbasha/terraform-ui.git
git clone https://github.com/siddharthshankarpaul/terraform-ui.git
```
#### change directory to the root of the project
#### run below command from root of project to create the artifact
Expand All @@ -25,16 +25,16 @@ java -jar target/terraform-ui-X.X.jar
http://localhost:8090/
```

## How to run as docker container ?
* TBD [working on this, will be out soon .. ]

# System requirement
* Java
* Maven
* Mysql

# Questions
* contact: mohinish_ce [@] yahoo dot com

## How to run as docker container ?
* docker-compose build
* docker-compose start


# Demo
![demo.gif](https://github.com/mohnishbasha/terraform-ui/blob/master/demo/demo.gif "demo")
![demo.gif](https://github.com/siddharthshankarpaul/terraform-ui/blob/master/demo/demo.gif "demo")
19 changes: 19 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: "3"

services:
web:
build: .
image: terra-ui
links:
- db
ports:
- 80:8090
command: ["./wait-for-db.sh", "3306"]

db:
image: mysql
environment:
- MYSQL_ROOT_PASSWORD=mysql
- MYSQL_DATABASE=terra
expose:
- 3306
12 changes: 10 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,26 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.4.RELEASE</version>
<version>2.1.2.RELEASE</version>
</parent>

<properties>
<java.version>1.8</java.version>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
Expand All @@ -37,6 +45,7 @@
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>

<!-- HikariCP connection pool -->
Expand All @@ -54,7 +63,6 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.6</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

import java.util.List;

import org.springframework.data.repository.CrudRepository;
import org.springframework.data.jpa.repository.JpaRepository;

import com.glitterlabs.terraformui.model.Cloud;
import com.glitterlabs.terraformui.model.Project;

/**
* The Interface CloudProjectRepository.
*/
public interface ProjectRepository extends CrudRepository<Project, Long> {
public interface ProjectRepository extends JpaRepository<Project, Long> {

/**
* Find by name.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public List<Project> findAllProjectsByCloud(@NotNull final String cloudType) {
* @return the project
*/
public Project findById(final Long projectId) {
return this.projectdao.findOne(projectId);
return this.projectdao.getOne(projectId);
}

/**
Expand All @@ -81,7 +81,7 @@ public void create(final Project project) throws IOException {
}

public void updateStatus(final Long projectId, final ProjectStatus status) {
final Project project = this.projectdao.findOne(projectId);
final Project project = findById(projectId);
project.setStatus(status);
this.projectdao.save(project);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class ResourceService {
* @throws IOException Signals that an I/O exception has occurred.
*/
public void create(final String projectId, final String name, final String content, final String resourceType) throws IOException {
final Project project = this.dao.findOne(Long.valueOf(projectId));
final Project project = this.dao.getOne(Long.valueOf(projectId));
final Path path = Paths.get(this.prop.getDirectoryPath(), project.getPath(), name);
if (StringUtils.equalsIgnoreCase(resourceType, "file")) {
Files.createFile(path);
Expand All @@ -59,7 +59,7 @@ public void create(final String projectId, final String name, final String conte

public List<Resource> findAllResources(final String projectId, final String subpath) {
List<Resource> result = new ArrayList<>();
final Project project = this.dao.findOne(Long.valueOf(projectId));
final Project project = this.dao.getOne(Long.valueOf(projectId));
if (project != null) {
try {
result = DirectoryUtil.getResources(Paths.get(this.prop.getDirectoryPath(), project.getPath(), subpath));
Expand All @@ -71,7 +71,7 @@ public List<Resource> findAllResources(final String projectId, final String subp
}

public String getResourceContent(final String projectId, final String resourcePath) throws IOException {
final Project project = this.dao.findOne(Long.valueOf(projectId));
final Project project = this.dao.getOne(Long.valueOf(projectId));
final Path path = Paths.get(this.prop.getDirectoryPath(), project.getPath(), resourcePath);
final byte[] bytes = Files.readAllBytes(path);
return new String(bytes);
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ spring.jpa.hibernate.ddl-auto=update
# Oracle settings
spring.datasource.url=jdbc:mysql://localhost:3306/terra
spring.datasource.username=root
spring.datasource.password=mysql
spring.datasource.password=mysql@123
spring.datasource.driver-class=com.mysql.jdbc.Driver

# HikariCP settings
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/global.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
directory.root=D:\\myProjects\\terraUI\\directory
terraform.exe.path=D:\\myProjects\\terraUI\\terraform.exe
directory.root=D:\\spaul\\myProjects\\terraUI\\directory
terraform.exe.path=D:\\spaul\\myProjects\\terraUI\\terraform.exe
4 changes: 2 additions & 2 deletions src/main/resources/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
<appender-ref ref="STDOUT"/>
</logger>

<logger name="com.mkyong" level="debug" additivity="false">
<logger name="com.glitterlabs" level="info" additivity="false">
<appender-ref ref="STDOUT"/>
</logger>

<root level="error">
<root level="info">
<appender-ref ref="STDOUT"/>
</root>

Expand Down
10 changes: 10 additions & 0 deletions wait-for-db.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

echo "Waiting for mysql"
until mysql -h"$1" -P"$1" -uroot -p"$MYSQL_ROOT_PASSWORD" &> /dev/null
do
printf "."
sleep 1
done

echo -e "\nmysql ready"