Skip to content

Commit

Permalink
feat: Removed mandatory variables (#34)
Browse files Browse the repository at this point in the history
* removed mandatory variables

* another commit
  • Loading branch information
diegolagospagopa authored May 22, 2023
1 parent 710b1c4 commit c8492da
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 29 deletions.
3 changes: 0 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
#
FROM maven:3.8.4-jdk-11-slim as buildtime

ENV MY_MANDATORY_SECRET=dummy \
MY_MANDATORY_VALUE=dummy

WORKDIR /build
COPY . .

Expand Down
8 changes: 1 addition & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,12 @@ Has liveness and readiness endpoints for k8s

You can use this simple application or locally or with docker compose, or with k8s usign the helm chart.

> Is mandatory to setup this two env variables:
> * MY_MANDATORY_VALUE
> * MY_MANDATORY_SECRET
This variables are for asserts of helm template

### Locally

Run the application usign this command

```sh
export MY_APP_COLOR=green MY_MANDATORY_VALUE=dummy MY_MANDATORY_SECRET=dummy && mvn spring-boot:run
export MY_APP_COLOR=green && mvn spring-boot:run
```

In this way you are able to set a color as env variable and run a spring boot server (with tomcat)
Expand Down
2 changes: 0 additions & 2 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,5 @@ services:
restart: always
environment:
- MY_APP_COLOR=red
- MY_MANDATORY_SECRET="very secret"
- MY_MANDATORY_VALUE="very value"
ports:
- "8080:8080"
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,13 @@ public class RootController {
@Value("${MY_APP_COLOR:}")
private String myAppColor;

@Value("${MY_MANDATORY_SECRET}")
private String myMandatorySecret;

@Value("${MY_MANDATORY_VALUE}")
private String myMandatoryValue;

@GetMapping("/")
public ModelAndView passParametersWithModelAndView() throws UnknownHostException {

ModelAndView modelAndView = new ModelAndView("indexTemplate");
modelAndView.addObject("color", getOneColor(myAppColor, colors));
modelAndView.addObject("hostname", InetAddress.getLocalHost().getHostName());
modelAndView.addObject("envs", envs());
modelAndView.addObject("myMandatorySecret", myMandatorySecret);
modelAndView.addObject("myMandatoryValue", myMandatoryValue);
return modelAndView;
}

Expand Down
9 changes: 0 additions & 9 deletions src/main/resources/templates/indexTemplate.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,6 @@
<div th:text="${hostname}">hostname</div>
</div>
<br/>
<div style="font-size: 1em; display: inline-flex;">
<div>myMandatorySecret: </div>
<div th:text="${myMandatorySecret}">myMandatorySecret</div>
</div>
<br/>
<div style="font-size: 1em; display: inline-flex;">
<div>myMandatoryValue: </div>
<div th:text="${myMandatoryValue}">myMandatoryValue</div>
</div>
</div>

<br/>
Expand Down

0 comments on commit c8492da

Please sign in to comment.