forked from strimzi/strimzi-kafka-operator
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathKubernetesVersion.java
More file actions
60 lines (51 loc) · 1.82 KB
/
KubernetesVersion.java
File metadata and controls
60 lines (51 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
* Copyright Strimzi authors.
* License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html).
*/
package io.strimzi.platform;
/**
* Represents Kubernetes version which Strimzi runs on
*/
public class KubernetesVersion implements Comparable<KubernetesVersion> {
private final int major;
private final int minor;
// Notable Kubernetes versions => this includes the minimal supported version and for example also any Kubernetes
// versions from some features are supported.
public static final KubernetesVersion V1_27 = new KubernetesVersion(1, 27);
public static final KubernetesVersion MINIMAL_SUPPORTED_VERSION = V1_27;
public static final int MINIMAL_SUPPORTED_MAJOR = MINIMAL_SUPPORTED_VERSION.major;
public static final int MINIMAL_SUPPORTED_MINOR = MINIMAL_SUPPORTED_VERSION.minor;
/**
* Constructs the Kubernetes version from major and minor version
*
* @param major Major Kubernetes version
* @param minor Minor Kubernetes version
*/
public KubernetesVersion(int major, int minor) {
this.major = major;
this.minor = minor;
}
@Override
public int hashCode() {
return major << 16 ^ minor;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
KubernetesVersion that = (KubernetesVersion) o;
return major == that.major && minor == that.minor;
}
@Override
public int compareTo(KubernetesVersion o) {
int cmp = Integer.compare(major, o.major);
if (cmp == 0) {
cmp = Integer.compare(minor, o.minor);
}
return cmp;
}
@Override
public String toString() {
return this.major + "." + this.minor;
}
}