-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from ErnestOrt/git-info
Git info
- Loading branch information
Showing
14 changed files
with
234 additions
and
31 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
1 change: 0 additions & 1 deletion
1
microservice-example-maven/src/main/resources/application.properties
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 |
---|---|---|
@@ -1,2 +1 @@ | ||
endpoints.shutdown.enabled=true | ||
logging.file=service.log |
49 changes: 49 additions & 0 deletions
49
...ne/src/main/java/org/ernest/applications/trampoline/collectors/InstanceInfoCollector.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,49 @@ | ||
package org.ernest.applications.trampoline.collectors; | ||
|
||
import org.ernest.applications.trampoline.entities.Instance; | ||
import org.ernest.applications.trampoline.entities.InstanceInfo; | ||
import org.ernest.applications.trampoline.services.EcosystemManager; | ||
import org.json.JSONObject; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.web.client.RestTemplate; | ||
|
||
import java.sql.Date; | ||
import java.sql.Timestamp; | ||
import java.text.SimpleDateFormat; | ||
|
||
@Component | ||
public class InstanceInfoCollector { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(TraceCollector.class); | ||
|
||
@Autowired | ||
EcosystemManager ecosystemManager; | ||
|
||
public InstanceInfo getInfo(String idInstance) { | ||
InstanceInfo info = new InstanceInfo(); | ||
|
||
Instance instance = ecosystemManager.getEcosystem().getInstances().stream().filter(i -> i.getId().equals(idInstance)).findAny().get(); | ||
info.setPomLocation(instance.getPomLocation()); | ||
try { | ||
JSONObject infoJson = new JSONObject(new RestTemplate().getForObject("http://127.0.0.1:" + instance.getPort() + instance.getActuatorPrefix() + "/info", String.class)); | ||
|
||
info.setBranch(infoJson.getJSONObject("git").get("branch").toString()); | ||
info.setCommitMessage(infoJson.getJSONObject("git").getJSONObject("commit").getJSONObject("message").get("full").toString()); | ||
info.setCommitOwner(infoJson.getJSONObject("git").getJSONObject("commit").getJSONObject("user").get("name").toString() + "["+infoJson.getJSONObject("git").getJSONObject("commit").getJSONObject("user").get("email").toString()+"]"); | ||
|
||
Long timestamp = Long.valueOf(infoJson.getJSONObject("git").getJSONObject("commit").get("time").toString()); | ||
info.setCommitDate(new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format( new Date(new Timestamp(timestamp).getTime()))); | ||
}catch (Exception e){ | ||
info.setBranch("-"); | ||
info.setCommitMessage("-"); | ||
info.setCommitOwner("-"); | ||
info.setCommitDate("-"); | ||
|
||
LOGGER.error("Not possible to retrieve git info for instance: ["+instance.getId()+"] hosted on port: ["+instance.getPort()+"]"); | ||
} | ||
return info; | ||
} | ||
} |
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
52 changes: 52 additions & 0 deletions
52
trampoline/src/main/java/org/ernest/applications/trampoline/entities/InstanceInfo.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,52 @@ | ||
package org.ernest.applications.trampoline.entities; | ||
|
||
|
||
public class InstanceInfo { | ||
|
||
private String pomLocation; | ||
private String branch; | ||
private String commitMessage; | ||
private String commitOwner; | ||
private String commitDate; | ||
|
||
public String getPomLocation() { | ||
return pomLocation; | ||
} | ||
|
||
public void setPomLocation(String pomLocation) { | ||
this.pomLocation = pomLocation; | ||
} | ||
|
||
public String getBranch() { | ||
return branch; | ||
} | ||
|
||
public void setBranch(String branch) { | ||
this.branch = branch; | ||
} | ||
|
||
public String getCommitMessage() { | ||
return commitMessage; | ||
} | ||
|
||
public void setCommitMessage(String commitMessage) { | ||
this.commitMessage = commitMessage; | ||
} | ||
|
||
public String getCommitOwner() { | ||
return commitOwner; | ||
} | ||
|
||
public void setCommitOwner(String commitOwner) { | ||
this.commitOwner = commitOwner; | ||
} | ||
|
||
public String getCommitDate() { | ||
return commitDate; | ||
} | ||
|
||
public void setCommitDate(String commitDate) { | ||
this.commitDate = commitDate; | ||
} | ||
} | ||
|
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
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
settings.folder.path.linux=/home/#userName/Documents/trampoline | ||
settings.folder.path.mac=/Users/#userName/Documents/trampoline | ||
settings.folder.path.windows=C:/Temp/trampoline | ||
settings.file.name=settings.txt | ||
settings.file.name=settings.txt | ||
trampoline.version=3.5 |
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
Oops, something went wrong.