|
3 | 3 |
|
4 | 4 | package oracle.kubernetes.operator.helpers; |
5 | 5 |
|
6 | | -import com.google.gson.Gson; |
7 | | -import com.google.gson.GsonBuilder; |
8 | | -import com.google.gson.JsonDeserializationContext; |
9 | | -import com.google.gson.JsonDeserializer; |
10 | | -import com.google.gson.JsonElement; |
11 | | -import com.google.gson.JsonParseException; |
12 | | -import com.google.gson.JsonPrimitive; |
13 | | -import com.google.gson.JsonSerializationContext; |
14 | | -import com.google.gson.JsonSerializer; |
15 | | -import io.kubernetes.client.ApiClient; |
16 | 6 | import io.kubernetes.client.ApiException; |
17 | | -import io.kubernetes.client.JSON; |
18 | 7 | import io.kubernetes.client.models.V1Secret; |
19 | 8 | import oracle.kubernetes.operator.logging.LoggingFacade; |
20 | 9 | import oracle.kubernetes.operator.logging.LoggingFactory; |
|
24 | 13 | import oracle.kubernetes.operator.work.Packet; |
25 | 14 | import oracle.kubernetes.operator.work.Step; |
26 | 15 |
|
27 | | -import org.joda.time.DateTime; |
28 | | - |
29 | | -import java.lang.reflect.Type; |
30 | | -import java.util.Base64; |
31 | | -import java.util.Date; |
32 | 16 | import java.util.HashMap; |
33 | 17 | import java.util.List; |
34 | 18 | import java.util.Map; |
@@ -174,43 +158,4 @@ private static Map<String, byte[]> harvestAdminSecretData(V1Secret secret) { |
174 | 158 | return secretData; |
175 | 159 | } |
176 | 160 |
|
177 | | - // Due to issue with kubernetes-client/java (com.google.gson.JsonSyntaxException when deserialize V1Secret) |
178 | | - // Issue #131 |
179 | | - // Add a custom Gson to the client so secrets can be decoded. |
180 | | - |
181 | | - /** |
182 | | - * Add custom Gson to client |
183 | | - * @param apiClient API client |
184 | | - */ |
185 | | - public static void addCustomGsonToClient(ApiClient apiClient) { |
186 | | - |
187 | | - LOGGER.entering(); |
188 | | - |
189 | | - JSON.DateTypeAdapter dateTypeAdapter = new JSON.DateTypeAdapter(); |
190 | | - JSON.SqlDateTypeAdapter sqlDateTypeAdapter = new JSON.SqlDateTypeAdapter(); |
191 | | - JSON.DateTimeTypeAdapter dateTimeTypeAdapter = new JSON.DateTimeTypeAdapter(); |
192 | | - |
193 | | - Gson customGson = |
194 | | - (new GsonBuilder()).registerTypeAdapter( |
195 | | - Date.class, dateTypeAdapter).registerTypeAdapter( |
196 | | - java.sql.Date.class, sqlDateTypeAdapter).registerTypeAdapter( |
197 | | - DateTime.class, dateTimeTypeAdapter).registerTypeAdapter( |
198 | | - byte[].class, new ByteArrayBase64StringTypeAdapter()).create(); |
199 | | - |
200 | | - apiClient.getJSON().setGson(customGson); |
201 | | - |
202 | | - LOGGER.exiting(); |
203 | | - } |
204 | | - |
205 | | - private static class ByteArrayBase64StringTypeAdapter implements JsonSerializer<byte[]>, JsonDeserializer<byte[]> { |
206 | | - |
207 | | - public byte[] deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { |
208 | | - return Base64.getUrlDecoder().decode(json.getAsString()); |
209 | | - } |
210 | | - |
211 | | - public JsonElement serialize(byte[] src, Type typeOfSrc, JsonSerializationContext context) { |
212 | | - return new JsonPrimitive(Base64.getUrlEncoder().encodeToString(src)); |
213 | | - } |
214 | | - } |
215 | | - |
216 | 161 | } |
0 commit comments