-
Notifications
You must be signed in to change notification settings - Fork 237
Fixes #318
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
Fixes #318
Changes from 8 commits
e77f2dd
4277b3d
174097f
8fa839e
4eb057b
f278c8f
2db6b5f
042d1e4
b791c4e
9edcde9
538e468
9c0ccbd
b9987a7
09ce889
6cde0be
ebb453e
d4d48cd
7608163
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,4 +15,6 @@ default Config getClientConfiguration() { | |
| } | ||
|
|
||
| Set<String> getKnownControllerNames(); | ||
|
|
||
| Version getVersion(); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| package io.javaoperatorsdk.operator.api.config; | ||
|
|
||
| import java.io.IOException; | ||
| import java.text.ParseException; | ||
| import java.text.SimpleDateFormat; | ||
| import java.time.Instant; | ||
| import java.util.Date; | ||
| import java.util.Properties; | ||
|
|
||
| public class Utils { | ||
|
|
||
| public static Version loadFromProperties() { | ||
| final var is = | ||
| Thread.currentThread().getContextClassLoader().getResourceAsStream("version.properties"); | ||
| final var properties = new Properties(); | ||
| try { | ||
| properties.load(is); | ||
| } catch (IOException e) { | ||
| e.printStackTrace(); | ||
| } | ||
|
|
||
| Date builtTime; | ||
| try { | ||
| builtTime = | ||
| // RFC 822 date is the default format used by git-commit-id-plugin | ||
| new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ") | ||
| .parse(properties.getProperty("git.build.time")); | ||
| } catch (ParseException e) { | ||
| builtTime = Date.from(Instant.EPOCH); | ||
| } | ||
| return new Version( | ||
| properties.getProperty("git.build.version", "unknown"), | ||
| properties.getProperty("git.commit.id.abbrev", "unknown"), | ||
| builtTime); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| package io.javaoperatorsdk.operator.api.config; | ||
|
|
||
| import java.util.Date; | ||
|
|
||
| public class Version { | ||
| private final String project; | ||
| private final String commit; | ||
| private final Date builtTime; | ||
|
|
||
| public Version(String project, String commit, Date builtTime) { | ||
| this.project = project; | ||
|
||
| this.commit = commit; | ||
| this.builtTime = builtTime; | ||
| } | ||
|
|
||
| public String getProject() { | ||
| return project; | ||
| } | ||
|
|
||
| public String getCommit() { | ||
| return commit; | ||
| } | ||
|
|
||
| public Date getBuiltTime() { | ||
| return builtTime; | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
immutable classes 🧡