@@ -35,7 +35,8 @@ public class ConfigHelper {
35
35
*/
36
36
public static boolean areEqual (Config thisConfig , Config thatConfig ) {
37
37
return areEqualCurrentContext (thisConfig , thatConfig )
38
- && areEqualToken (thisConfig , thatConfig );
38
+ && areEqualCluster (thisConfig , thatConfig )
39
+ && areEqualAuthInfo (thisConfig , thatConfig );
39
40
}
40
41
41
42
/**
@@ -108,20 +109,73 @@ private static boolean areEqualContext(NamedContext thisContext, NamedContext th
108
109
* @see NamedContext
109
110
* @see Context
110
111
*/
111
- private static boolean areEqualContext (Context thisContext , Context thatContext ) {
112
+ public static boolean areEqualContext (Context thisContext , Context thatContext ) {
112
113
if (thisContext == null ) {
113
114
return thatContext == null ;
114
115
} else if (thatContext == null ) {
115
116
return false ;
116
117
}
117
118
118
- if (!Objects .equals (thisContext .getCluster (), thatContext .getCluster ())){
119
+ return Objects .equals (thisContext .getCluster (), thatContext .getCluster ())
120
+ && Objects .equals (thisContext .getNamespace (), thatContext .getNamespace ())
121
+ && Objects .equals (thisContext .getUser (), thatContext .getUser ());
122
+ }
123
+
124
+ public static boolean areEqualCluster (Config thisConfig , Config thatConfig ) {
125
+ if (thisConfig == null ) {
126
+ return thatConfig == null ;
127
+ } else if (thatConfig == null ) {
119
128
return false ;
120
- } else if (!Objects .equals (thisContext .getNamespace (), thatContext .getNamespace ())){
129
+ }
130
+
131
+ return Objects .equals (thisConfig .getMasterUrl (), thatConfig .getMasterUrl ())
132
+ && areEqualTrustCerts (thisConfig , thatConfig )
133
+ && areEqualProxy (thisConfig , thatConfig )
134
+ && areEqualAuthInfo (thisConfig , thatConfig );
135
+ }
136
+
137
+ private static boolean areEqualProxy (Config thisConfig , Config thatConfig ) {
138
+ if (thisConfig == null ) {
139
+ return thatConfig == null ;
140
+ } else if (thatConfig == null ) {
121
141
return false ;
122
- } else {
123
- return Objects .equals (thisContext .getUser (), thatContext .getUser ());
124
142
}
143
+
144
+ return Objects .equals (thisConfig .getHttpProxy (), thatConfig .getHttpProxy ())
145
+ && Objects .equals (thisConfig .getHttpsProxy (), thatConfig .getHttpsProxy ())
146
+ && Objects .equals (thisConfig .getProxyUsername (), thatConfig .getProxyUsername ())
147
+ && Objects .equals (thisConfig .getProxyPassword (), thatConfig .getProxyPassword ());
148
+ }
149
+
150
+ private static boolean areEqualTrustCerts (Config thisConfig , Config thatConfig ) {
151
+ if (thisConfig == null ) {
152
+ return thatConfig == null ;
153
+ } else if (thatConfig == null ) {
154
+ return false ;
155
+ }
156
+
157
+ return thisConfig .isTrustCerts () == thatConfig .isTrustCerts ()
158
+ && thisConfig .isDisableHostnameVerification () == thatConfig .isDisableHostnameVerification ()
159
+ && Objects .equals (thisConfig .getCaCertData (), thatConfig .getCaCertData ())
160
+ && Objects .equals (thisConfig .getCaCertFile (), thatConfig .getCaCertFile ());
161
+ }
162
+
163
+ public static boolean areEqualAuthInfo (Config thisConfig , Config thatConfig ) {
164
+ if (thisConfig == null ) {
165
+ return thatConfig == null ;
166
+ } else if (thatConfig == null ) {
167
+ return false ;
168
+ }
169
+
170
+ return Objects .equals (thisConfig .getClientCertFile (), thatConfig .getClientCertFile ())
171
+ && Objects .equals (thisConfig .getClientCertData (), thatConfig .getClientCertData ())
172
+ && Objects .equals (thisConfig .getClientKeyFile (), thatConfig .getClientKeyFile ())
173
+ && Objects .equals (thisConfig .getClientKeyData (), thatConfig .getClientKeyData ())
174
+ && Objects .equals (thisConfig .getClientKeyAlgo (), thatConfig .getClientKeyAlgo ())
175
+ && Objects .equals (thisConfig .getUsername (), thatConfig .getUsername ())
176
+ && Objects .equals (thisConfig .getPassword (), thatConfig .getPassword ())
177
+ && areEqualProxy (thisConfig , thatConfig )
178
+ && areEqualToken (thisConfig , thatConfig );
125
179
}
126
180
127
181
/**
0 commit comments