-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3898 from yue9944882/sync-up-master
Chore: Sync up repo infra assets from master branch
- Loading branch information
Showing
6 changed files
with
220 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
From eeb5069c974d3146495f8a9dc52653f029d3cc2d Mon Sep 17 00:00:00 2001 | ||
From: Min Jin <minkimzz@amazon.com> | ||
Date: Tue, 4 Feb 2025 11:59:25 -0800 | ||
Subject: [PATCH] manually apply JSON patch | ||
|
||
--- | ||
.../io/kubernetes/client/openapi/JSON.java | 36 ++++++++++++++++--- | ||
1 file changed, 32 insertions(+), 4 deletions(-) | ||
|
||
diff --git a/kubernetes/src/main/java/io/kubernetes/client/openapi/JSON.java b/kubernetes/src/main/java/io/kubernetes/client/openapi/JSON.java | ||
index dda3ec708..fe902b293 100644 | ||
--- a/kubernetes/src/main/java/io/kubernetes/client/openapi/JSON.java | ||
+++ b/kubernetes/src/main/java/io/kubernetes/client/openapi/JSON.java | ||
@@ -23,6 +23,9 @@ import com.google.gson.JsonElement; | ||
import io.gsonfire.GsonFireBuilder; | ||
import io.gsonfire.TypeSelector; | ||
|
||
+import io.kubernetes.client.gson.V1MetadataExclusionStrategy; | ||
+import io.kubernetes.client.gson.V1StatusPreProcessor; | ||
+import io.kubernetes.client.openapi.models.V1Status; | ||
import okio.ByteString; | ||
|
||
import java.io.IOException; | ||
@@ -35,6 +38,9 @@ import java.time.OffsetDateTime; | ||
import java.time.ZoneId; | ||
import java.time.ZoneOffset; | ||
import java.time.format.DateTimeFormatter; | ||
+import java.time.format.DateTimeFormatterBuilder; | ||
+import java.time.format.DateTimeParseException; | ||
+import java.time.temporal.ChronoField; | ||
import java.util.Date; | ||
import java.util.Locale; | ||
import java.util.Map; | ||
@@ -50,9 +56,20 @@ import java.util.TimeZone; | ||
public class JSON { | ||
private static Gson gson; | ||
private static boolean isLenientOnJson = false; | ||
+ | ||
+ private static final DateTimeFormatter RFC3339MICRO_FORMATTER = | ||
+ new DateTimeFormatterBuilder() | ||
+ .parseDefaulting(ChronoField.OFFSET_SECONDS, 0) | ||
+ .append(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss")) | ||
+ .optionalStart() | ||
+ .appendFraction(ChronoField.NANO_OF_SECOND, 6, 6, true) | ||
+ .optionalEnd() | ||
+ .appendLiteral("Z") | ||
+ .toFormatter(); | ||
+ | ||
private static DateTypeAdapter dateTypeAdapter = new DateTypeAdapter(); | ||
private static SqlDateTypeAdapter sqlDateTypeAdapter = new SqlDateTypeAdapter(); | ||
- private static OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter = new OffsetDateTimeTypeAdapter(); | ||
+ private static OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter = new OffsetDateTimeTypeAdapter(RFC3339MICRO_FORMATTER); | ||
private static LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter(); | ||
private static ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter(); | ||
|
||
@@ -65,8 +82,11 @@ public class JSON { | ||
public static GsonBuilder createGson() { | ||
GsonFireBuilder fireBuilder = new GsonFireBuilder() | ||
; | ||
- GsonBuilder builder = fireBuilder.createGsonBuilder(); | ||
- return builder; | ||
+ GsonBuilder builder = | ||
+ fireBuilder | ||
+ .registerPreProcessor(V1Status.class, new V1StatusPreProcessor()) | ||
+ .createGsonBuilder(); | ||
+ return builder.setExclusionStrategies(new V1MetadataExclusionStrategy()); | ||
} | ||
|
||
private static String getDiscriminatorValue(JsonElement readElement, String discriminatorField) { | ||
@@ -793,11 +813,14 @@ public class JSON { | ||
|
||
@Override | ||
public void write(JsonWriter out, byte[] value) throws IOException { | ||
+ boolean oldHtmlSafe = out.isHtmlSafe(); | ||
+ out.setHtmlSafe(false); | ||
if (value == null) { | ||
out.nullValue(); | ||
} else { | ||
out.value(ByteString.of(value).base64()); | ||
} | ||
+ out.setHtmlSafe(oldHtmlSafe); | ||
} | ||
|
||
@Override | ||
@@ -853,7 +876,12 @@ public class JSON { | ||
if (date.endsWith("+0000")) { | ||
date = date.substring(0, date.length()-5) + "Z"; | ||
} | ||
- return OffsetDateTime.parse(date, formatter); | ||
+ try { | ||
+ return OffsetDateTime.parse(date, formatter); | ||
+ } catch (DateTimeParseException e) { | ||
+ // backward-compatibility for ISO8601 timestamp format | ||
+ return OffsetDateTime.parse(date, DateTimeFormatter.ISO_OFFSET_DATE_TIME); | ||
+ } | ||
} | ||
} | ||
} | ||
-- | ||
2.40.0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
From ff206c043bea0e87076e1f981634473b3522b1df Mon Sep 17 00:00:00 2001 | ||
From: Min Jin <minkimzz@amazon.com> | ||
Date: Tue, 4 Feb 2025 12:07:01 -0800 | ||
Subject: [PATCH] manually apply list-meta patch | ||
|
||
Signed-off-by: Min Jin <minkimzz@amazon.com> | ||
--- | ||
.../java/io/kubernetes/client/openapi/models/V1ListMeta.java | 3 ++- | ||
1 file changed, 2 insertions(+), 1 deletion(-) | ||
|
||
diff --git a/kubernetes/src/main/java/io/kubernetes/client/openapi/models/V1ListMeta.java b/kubernetes/src/main/java/io/kubernetes/client/openapi/models/V1ListMeta.java | ||
index 4ea44ec7f..1ef9ec2a6 100644 | ||
--- a/kubernetes/src/main/java/io/kubernetes/client/openapi/models/V1ListMeta.java | ||
+++ b/kubernetes/src/main/java/io/kubernetes/client/openapi/models/V1ListMeta.java | ||
@@ -265,7 +265,8 @@ public class V1ListMeta { | ||
@Override | ||
public V1ListMeta read(JsonReader in) throws IOException { | ||
JsonElement jsonElement = elementAdapter.read(in); | ||
- validateJsonElement(jsonElement); | ||
+ // Disable validation so delete API can tolerate non-status return object (graceful deletion) | ||
+ // validateJsonObject(jsonObj); | ||
return thisAdapter.fromJsonTree(jsonElement); | ||
} | ||
|
||
-- | ||
2.40.0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
From 2f237a9b0065778c20c97350fb5aea3d54974e07 Mon Sep 17 00:00:00 2001 | ||
From: Min Jin <minkimzz@amazon.com> | ||
Date: Tue, 4 Feb 2025 11:19:21 -0800 | ||
Subject: [PATCH] applying scripts/patches/secret.diff | ||
|
||
Signed-off-by: Min Jin <minkimzz@amazon.com> | ||
--- | ||
.../java/io/kubernetes/client/openapi/models/V1Secret.java | 3 ++- | ||
1 file changed, 2 insertions(+), 1 deletion(-) | ||
|
||
diff --git a/kubernetes/src/main/java/io/kubernetes/client/openapi/models/V1Secret.java b/kubernetes/src/main/java/io/kubernetes/client/openapi/models/V1Secret.java | ||
index 4316c3275..54c8cb914 100644 | ||
--- a/kubernetes/src/main/java/io/kubernetes/client/openapi/models/V1Secret.java | ||
+++ b/kubernetes/src/main/java/io/kubernetes/client/openapi/models/V1Secret.java | ||
@@ -18,6 +18,7 @@ import com.google.gson.annotations.JsonAdapter; | ||
import com.google.gson.annotations.SerializedName; | ||
import com.google.gson.stream.JsonReader; | ||
import com.google.gson.stream.JsonWriter; | ||
+import io.kubernetes.client.custom.MapUtils; | ||
import io.kubernetes.client.openapi.models.V1ObjectMeta; | ||
import io.swagger.annotations.ApiModel; | ||
import io.swagger.annotations.ApiModelProperty; | ||
@@ -254,7 +255,7 @@ public class V1Secret implements io.kubernetes.client.common.KubernetesObject { | ||
} | ||
V1Secret v1Secret = (V1Secret) o; | ||
return Objects.equals(this.apiVersion, v1Secret.apiVersion) && | ||
- Objects.equals(this.data, v1Secret.data) && | ||
+ MapUtils.equals(this.data, v1Secret.data) && | ||
Objects.equals(this.immutable, v1Secret.immutable) && | ||
Objects.equals(this.kind, v1Secret.kind) && | ||
Objects.equals(this.metadata, v1Secret.metadata) && | ||
-- | ||
2.40.0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
From 8c5816990a40eb9ad57dda33bd7fb5cfdbcd3627 Mon Sep 17 00:00:00 2001 | ||
From: Min Jin <minkimzz@amazon.com> | ||
Date: Tue, 4 Feb 2025 12:08:35 -0800 | ||
Subject: [PATCH] manual apply status patch | ||
|
||
Signed-off-by: Min Jin <minkimzz@amazon.com> | ||
--- | ||
.../java/io/kubernetes/client/openapi/models/V1Status.java | 3 ++- | ||
1 file changed, 2 insertions(+), 1 deletion(-) | ||
|
||
diff --git a/kubernetes/src/main/java/io/kubernetes/client/openapi/models/V1Status.java b/kubernetes/src/main/java/io/kubernetes/client/openapi/models/V1Status.java | ||
index 8faeacd29..e03d69e70 100644 | ||
--- a/kubernetes/src/main/java/io/kubernetes/client/openapi/models/V1Status.java | ||
+++ b/kubernetes/src/main/java/io/kubernetes/client/openapi/models/V1Status.java | ||
@@ -389,7 +389,8 @@ public class V1Status { | ||
@Override | ||
public V1Status read(JsonReader in) throws IOException { | ||
JsonElement jsonElement = elementAdapter.read(in); | ||
- validateJsonElement(jsonElement); | ||
+ // Disable validation so delete API can tolerate non-status return object (graceful deletion) | ||
+ // validateJsonObject(jsonObj); | ||
return thisAdapter.fromJsonTree(jsonElement); | ||
} | ||
|
||
-- | ||
2.40.0 | ||
|