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