-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
930 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package io.codeka.gaia.bo; | ||
|
||
import io.codeka.gaia.bo.backend.Backend; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* This class represents a terraform modules instances. | ||
* | ||
* It references the module it is based on, with all the values of its variables. | ||
* It also has a backend configuration, and a provider configuration (in terraform terms). | ||
*/ | ||
public class Stack { | ||
|
||
/** | ||
* This stack's id | ||
*/ | ||
private String id; | ||
|
||
/** | ||
* The id of the referenced module | ||
*/ | ||
private String moduleId; | ||
|
||
/** | ||
* The variable values of the module | ||
*/ | ||
private Map<String, String> variableValues = new HashMap<>(); | ||
|
||
/** | ||
* The name of the stack | ||
*/ | ||
private String name; | ||
|
||
/** | ||
* The provider spec | ||
*/ | ||
private String providerSpec; | ||
|
||
public String getId() { | ||
return id; | ||
} | ||
|
||
public void setId(String id) { | ||
this.id = id; | ||
} | ||
|
||
public String getModuleId() { | ||
return moduleId; | ||
} | ||
|
||
public void setModuleId(String moduleId) { | ||
this.moduleId = moduleId; | ||
} | ||
|
||
public Map<String, String> getVariableValues() { | ||
return variableValues; | ||
} | ||
|
||
public void setVariableValues(Map<String, String> variableValues) { | ||
this.variableValues = variableValues; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public String getProviderSpec() { | ||
return providerSpec; | ||
} | ||
|
||
public void setProviderSpec(String providerSpec) { | ||
this.providerSpec = providerSpec; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package io.codeka.gaia.bo; | ||
|
||
import io.codeka.gaia.bo.backend.Terraform; | ||
|
||
public class TerraformBackend { | ||
|
||
private Terraform terraform; | ||
|
||
public Terraform getTerraform() { | ||
if(terraform == null){ | ||
terraform = new Terraform(); | ||
} | ||
return terraform; | ||
} | ||
|
||
public void setTerraform(Terraform terraform) { | ||
this.terraform = terraform; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package io.codeka.gaia.bo.backend; | ||
|
||
public class Backend { | ||
private Http http; | ||
|
||
public Http getHttp() { | ||
if(http == null){ | ||
http = new Http(); | ||
} | ||
return http; | ||
} | ||
|
||
public void setHttp(Http http) { | ||
this.http = http; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package io.codeka.gaia.bo.backend; | ||
|
||
public class Http { | ||
private String address; | ||
|
||
public String getAddress() { | ||
return address; | ||
} | ||
|
||
public void setAddress(String address) { | ||
this.address = address; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package io.codeka.gaia.bo.backend; | ||
|
||
public class Terraform { | ||
private Backend backend; | ||
|
||
public Backend getBackend() { | ||
if(backend == null){ | ||
backend = new Backend(); | ||
} | ||
return backend; | ||
} | ||
|
||
public void setBackend(Backend backend) { | ||
this.backend = backend; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package io.codeka.gaia.config; | ||
|
||
import io.codeka.gaia.bo.Stack; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.data.rest.core.config.RepositoryRestConfiguration; | ||
|
||
@Configuration | ||
public class RepositoryConfig { | ||
|
||
@Autowired | ||
public void configureRest(RepositoryRestConfiguration repositoryRestConfiguration){ | ||
repositoryRestConfiguration.exposeIdsFor(Stack.class); | ||
|
||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
src/main/java/io/codeka/gaia/controller/StackController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package io.codeka.gaia.controller; | ||
|
||
import io.codeka.gaia.repository.StackRepository; | ||
import io.codeka.gaia.repository.TerraformModuleRepository; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.ui.Model; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
|
||
@Controller | ||
public class StackController { | ||
|
||
private TerraformModuleRepository terraformModuleRepository; | ||
|
||
private StackRepository stackRepository; | ||
|
||
private Logger log = LoggerFactory.getLogger(StackController.class); | ||
|
||
@Autowired | ||
public StackController(TerraformModuleRepository terraformModuleRepository, StackRepository stackRepository) { | ||
this.terraformModuleRepository = terraformModuleRepository; | ||
this.stackRepository = stackRepository; | ||
} | ||
|
||
@GetMapping("/stacks") | ||
public String listStacks(Model model){ | ||
model.addAttribute("stacks", stackRepository.findAll()); | ||
|
||
return "stacks"; | ||
} | ||
|
||
@GetMapping("/stacks/{stackId}") | ||
public String editStack(@PathVariable String stackId, Model model){ | ||
// checking if the stack exists | ||
// TODO throw an exception (404) if not | ||
if(stackRepository.existsById(stackId)){ | ||
model.addAttribute("stackId", stackId); | ||
} | ||
return "stack"; | ||
} | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/io/codeka/gaia/repository/StackRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package io.codeka.gaia.repository; | ||
|
||
import io.codeka.gaia.bo.Stack; | ||
import org.springframework.data.mongodb.repository.MongoRepository; | ||
import org.springframework.data.rest.core.annotation.RepositoryRestResource; | ||
|
||
/** | ||
* Repository for stacks | ||
*/ | ||
@RepositoryRestResource | ||
public interface StackRepository extends MongoRepository<Stack, String>{ | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/io/codeka/gaia/service/RunTerraformService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package io.codeka.gaia.service; | ||
|
||
import com.spotify.docker.client.DefaultDockerClient; | ||
import com.spotify.docker.client.DockerClient; | ||
import com.spotify.docker.client.exceptions.DockerCertificateException; | ||
import com.spotify.docker.client.exceptions.DockerException; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
public class RunTerraformService { | ||
|
||
|
||
public void runTerraform() throws DockerException, InterruptedException, DockerCertificateException { | ||
|
||
} | ||
} |
Oops, something went wrong.