|
16 | 16 |
|
17 | 17 | package io.fabric8.kubernetes.client; |
18 | 18 |
|
| 19 | +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
| 20 | +import lombok.Getter; |
| 21 | + |
19 | 22 | import java.text.ParseException; |
20 | 23 | import java.text.SimpleDateFormat; |
21 | 24 | import java.util.Date; |
22 | 25 |
|
| 26 | +@JsonIgnoreProperties(ignoreUnknown = true) |
| 27 | +@Getter |
23 | 28 | public class VersionInfo { |
24 | 29 | public static final class VersionKeys { |
25 | 30 | private VersionKeys() { |
26 | 31 | } |
27 | 32 |
|
28 | | - public static final String BUILD_DATE = "buildDate"; |
29 | | - public static final String GIT_COMMIT = "gitCommit"; |
30 | | - public static final String GIT_VERSION = "gitVersion"; |
31 | | - public static final String MAJOR = "major"; |
32 | | - public static final String MINOR = "minor"; |
33 | | - public static final String GIT_TREE_STATE = "gitTreeState"; |
34 | | - public static final String PLATFORM = "platform"; |
35 | | - public static final String GO_VERSION = "goVersion"; |
36 | | - public static final String COMPILER = "compiler"; |
37 | 33 | public static final String BUILD_DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ssX"; |
38 | 34 | } |
39 | 35 |
|
40 | | - private Date buildDate; |
41 | | - private String gitCommit; |
42 | | - private String gitVersion; |
43 | 36 | private String major; |
44 | 37 | private String minor; |
| 38 | + private Integer emulationMajor; |
| 39 | + private Integer emulationMinor; |
| 40 | + private Integer minCompatibilityMajor; |
| 41 | + private Integer minCompatibilityMinor; |
| 42 | + private String gitCommit; |
| 43 | + private String gitVersion; |
45 | 44 | private String gitTreeState; |
46 | | - private String platform; |
| 45 | + private Date buildDate; |
47 | 46 | private String goVersion; |
48 | 47 | private String compiler; |
49 | | - |
50 | | - public Date getBuildDate() { |
51 | | - return buildDate; |
52 | | - } |
53 | | - |
54 | | - public String getGitCommit() { |
55 | | - return gitCommit; |
56 | | - } |
57 | | - |
58 | | - public String getGitVersion() { |
59 | | - return gitVersion; |
60 | | - } |
61 | | - |
62 | | - public String getMajor() { |
63 | | - return major; |
64 | | - } |
65 | | - |
66 | | - public String getMinor() { |
67 | | - return minor; |
68 | | - } |
69 | | - |
70 | | - public String getGitTreeState() { |
71 | | - return gitTreeState; |
72 | | - } |
73 | | - |
74 | | - public String getPlatform() { |
75 | | - return platform; |
76 | | - } |
77 | | - |
78 | | - public String getGoVersion() { |
79 | | - return goVersion; |
80 | | - } |
81 | | - |
82 | | - public String getCompiler() { |
83 | | - return compiler; |
84 | | - } |
| 48 | + private String platform; |
85 | 49 |
|
86 | 50 | private VersionInfo() { |
87 | 51 | } |
88 | 52 |
|
89 | | - public static class Builder { |
90 | | - private VersionInfo versionInfo = new VersionInfo(); |
| 53 | + public static final class Builder { |
| 54 | + private String major; |
| 55 | + private String minor; |
| 56 | + private Integer emulationMajor; |
| 57 | + private Integer emulationMinor; |
| 58 | + private Integer minCompatibilityMajor; |
| 59 | + private Integer minCompatibilityMinor; |
| 60 | + private String gitCommit; |
| 61 | + private String gitVersion; |
| 62 | + private String gitTreeState; |
| 63 | + private Date buildDate; |
| 64 | + private String goVersion; |
| 65 | + private String compiler; |
| 66 | + private String platform; |
91 | 67 |
|
92 | 68 | public Builder() { |
93 | 69 | } |
94 | 70 |
|
95 | 71 | public Builder(VersionInfo versionInfo) { |
96 | 72 | if (versionInfo != null) { |
97 | | - this.versionInfo.buildDate = versionInfo.getBuildDate(); |
98 | | - this.versionInfo.gitCommit = versionInfo.getGitCommit(); |
99 | | - this.versionInfo.gitVersion = versionInfo.getGitVersion(); |
100 | | - this.versionInfo.major = versionInfo.getMajor(); |
101 | | - this.versionInfo.minor = versionInfo.getMinor(); |
102 | | - this.versionInfo.gitTreeState = versionInfo.getGitTreeState(); |
103 | | - this.versionInfo.platform = versionInfo.getPlatform(); |
104 | | - this.versionInfo.goVersion = versionInfo.getGoVersion(); |
105 | | - this.versionInfo.compiler = versionInfo.getCompiler(); |
| 73 | + this.major = versionInfo.getMajor(); |
| 74 | + this.minor = versionInfo.getMinor(); |
| 75 | + this.emulationMajor = versionInfo.getEmulationMajor(); |
| 76 | + this.emulationMinor = versionInfo.getEmulationMinor(); |
| 77 | + this.minCompatibilityMajor = versionInfo.getMinCompatibilityMajor(); |
| 78 | + this.minCompatibilityMinor = versionInfo.getMinCompatibilityMinor(); |
| 79 | + this.gitCommit = versionInfo.getGitCommit(); |
| 80 | + this.gitVersion = versionInfo.getGitVersion(); |
| 81 | + this.gitTreeState = versionInfo.getGitTreeState(); |
| 82 | + this.buildDate = versionInfo.getBuildDate(); |
| 83 | + this.goVersion = versionInfo.getGoVersion(); |
| 84 | + this.compiler = versionInfo.getCompiler(); |
| 85 | + this.platform = versionInfo.getPlatform(); |
106 | 86 | } |
107 | 87 | } |
108 | 88 |
|
109 | 89 | public Builder withBuildDate(String buildDate) throws ParseException { |
110 | 90 | if (buildDate != null) { |
111 | | - this.versionInfo.buildDate = new SimpleDateFormat(VersionKeys.BUILD_DATE_FORMAT).parse(buildDate); |
| 91 | + this.buildDate = new SimpleDateFormat(VersionKeys.BUILD_DATE_FORMAT).parse(buildDate); |
112 | 92 | } |
113 | 93 | return this; |
114 | 94 | } |
115 | 95 |
|
116 | | - public Builder withGitCommit(String gitCommit) { |
117 | | - this.versionInfo.gitCommit = gitCommit; |
| 96 | + public Builder withMajor(String major) { |
| 97 | + this.major = major; |
118 | 98 | return this; |
119 | 99 | } |
120 | 100 |
|
121 | | - public Builder withGitVersion(String gitVersion) { |
122 | | - this.versionInfo.gitVersion = gitVersion; |
| 101 | + public Builder withMinor(String minor) { |
| 102 | + this.minor = minor; |
123 | 103 | return this; |
124 | 104 | } |
125 | 105 |
|
126 | | - public Builder withMajor(String major) { |
127 | | - this.versionInfo.major = major; |
| 106 | + public Builder withEmulationMajor(Integer emulationMajor) { |
| 107 | + this.emulationMajor = emulationMajor; |
128 | 108 | return this; |
129 | 109 | } |
130 | 110 |
|
131 | | - public Builder withMinor(String minor) { |
132 | | - this.versionInfo.minor = minor; |
| 111 | + public Builder withEmulationMinor(Integer emulationMinor) { |
| 112 | + this.emulationMinor = emulationMinor; |
| 113 | + return this; |
| 114 | + } |
| 115 | + |
| 116 | + public Builder withMinCompatibilityMajor(Integer minCompatibilityMajor) { |
| 117 | + this.minCompatibilityMajor = minCompatibilityMajor; |
| 118 | + return this; |
| 119 | + } |
| 120 | + |
| 121 | + public Builder withMinCompatibilityMinor(Integer minCompatibilityMinor) { |
| 122 | + this.minCompatibilityMinor = minCompatibilityMinor; |
| 123 | + return this; |
| 124 | + } |
| 125 | + |
| 126 | + public Builder withGitCommit(String gitCommit) { |
| 127 | + this.gitCommit = gitCommit; |
| 128 | + return this; |
| 129 | + } |
| 130 | + |
| 131 | + public Builder withGitVersion(String gitVersion) { |
| 132 | + this.gitVersion = gitVersion; |
133 | 133 | return this; |
134 | 134 | } |
135 | 135 |
|
136 | 136 | public Builder withGitTreeState(String gitTreeState) { |
137 | | - this.versionInfo.gitTreeState = gitTreeState; |
| 137 | + this.gitTreeState = gitTreeState; |
138 | 138 | return this; |
139 | 139 | } |
140 | 140 |
|
141 | | - public Builder withPlatform(String platform) { |
142 | | - this.versionInfo.platform = platform; |
| 141 | + public Builder withBuildDate(Date buildDate) { |
| 142 | + this.buildDate = buildDate; |
143 | 143 | return this; |
144 | 144 | } |
145 | 145 |
|
146 | 146 | public Builder withGoVersion(String goVersion) { |
147 | | - this.versionInfo.goVersion = goVersion; |
| 147 | + this.goVersion = goVersion; |
148 | 148 | return this; |
149 | 149 | } |
150 | 150 |
|
151 | 151 | public Builder withCompiler(String compiler) { |
152 | | - this.versionInfo.compiler = compiler; |
| 152 | + this.compiler = compiler; |
| 153 | + return this; |
| 154 | + } |
| 155 | + |
| 156 | + public Builder withPlatform(String platform) { |
| 157 | + this.platform = platform; |
153 | 158 | return this; |
154 | 159 | } |
155 | 160 |
|
156 | 161 | public VersionInfo build() { |
| 162 | + VersionInfo versionInfo = new VersionInfo(); |
| 163 | + versionInfo.compiler = this.compiler; |
| 164 | + versionInfo.gitCommit = this.gitCommit; |
| 165 | + versionInfo.minCompatibilityMajor = this.minCompatibilityMajor; |
| 166 | + versionInfo.goVersion = this.goVersion; |
| 167 | + versionInfo.platform = this.platform; |
| 168 | + versionInfo.gitVersion = this.gitVersion; |
| 169 | + versionInfo.major = this.major; |
| 170 | + versionInfo.emulationMajor = this.emulationMajor; |
| 171 | + versionInfo.emulationMinor = this.emulationMinor; |
| 172 | + versionInfo.minor = this.minor; |
| 173 | + versionInfo.minCompatibilityMinor = this.minCompatibilityMinor; |
| 174 | + versionInfo.gitTreeState = this.gitTreeState; |
| 175 | + versionInfo.buildDate = this.buildDate; |
157 | 176 | return versionInfo; |
158 | 177 | } |
159 | 178 | } |
|
0 commit comments