Skip to content

Commit

Permalink
chore (deps) : Directly rely on upstream zjsonpatch repository instea…
Browse files Browse the repository at this point in the history
…d of fabric8io fork

+ Add a new module zjsonpatch that would directly include
  `com.flipkart.zjsonpatch:zjsonpatch` dependency excluding
  `org.apache.commons:commons-collections4`.
+ Port required method `ListUtils.longestCommonSubsequence` and related
  classes inside zjsonpatch module

Signed-off-by: Rohan Kumar <[email protected]>
  • Loading branch information
rohanKanojia committed Aug 30, 2024
1 parent 81b1fea commit 848e90f
Show file tree
Hide file tree
Showing 15 changed files with 1,393 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
* `Config.errorMessages` has been removed. Please use Kubernetes status messages directly.
* Fix #6138: Removed unused `io:fabric8:kubernetes-model` artifact
* Fix #6156: Removed deprecated extension `io:fabric8:service-catalog`
* Fix #5480: Migrate from `io.fabric8:zjsonpatch` to `com.flipkart.zjsonpatch:zjsonpatch` . In case you're relying on `io.fabric8.zjsonpatch.*` classes, you need to migrate to `com.flipkart.zjsonpatch.*` classes.

### 6.13.3 (2024-08-13)

Expand Down
1 change: 0 additions & 1 deletion kubernetes-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>zjsonpatch</artifactId>
<version>${zjsonpatch.version}</version>
</dependency>

<dependency>
Expand Down
2 changes: 1 addition & 1 deletion platforms/karaf/features/src/main/resources/feature.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<bundle dependency='true'>mvn:org.ow2.asm/asm-tree/${asm.bundle.version}</bundle>
<bundle dependency='true'>mvn:org.ow2.asm/asm-util/${asm.bundle.version}</bundle>
<bundle dependency='true'>mvn:io.fabric8/kubernetes-model-common/${project.version}</bundle>
<bundle>mvn:io.fabric8/zjsonpatch/${zjsonpatch.version}</bundle>
<bundle>mvn:io.fabric8/zjsonpatch/${project.version}</bundle>

<bundle>mvn:io.fabric8/kubernetes-model-core/${project.version}</bundle>
<bundle>mvn:io.fabric8/kubernetes-model-rbac/${project.version}</bundle>
Expand Down
19 changes: 16 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
<maven-core.version>3.9.9</maven-core.version>
<maven-plugin-annotations.version>3.15.0</maven-plugin-annotations.version>
<vertx.version>4.5.9</vertx.version>
<zjsonpatch.version>0.3.0</zjsonpatch.version>
<zjsonpatch.version>0.4.16</zjsonpatch.version>

<!-- API versions -->
<jsr305.version>3.0.2</jsr305.version>
Expand Down Expand Up @@ -226,6 +226,7 @@
<module>httpclient-vertx</module>
<module>kubernetes-client-deps-compatibility-tests</module>
<module>log4j</module>
<module>zjsonpatch</module>
</modules>

<dependencyManagement>
Expand Down Expand Up @@ -715,6 +716,11 @@
<artifactId>kube-api-test-client-inject</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>zjsonpatch</artifactId>
<version>${project.version}</version>
</dependency>


<!-- Jackson dependencies, imported as a BOM -->
Expand Down Expand Up @@ -890,12 +896,19 @@
<optional>true</optional>
</dependency>

<!-- Testing and Mocking -->
<dependency>
<groupId>io.fabric8</groupId>
<groupId>com.flipkart.zjsonpatch</groupId>
<artifactId>zjsonpatch</artifactId>
<version>${zjsonpatch.version}</version>
<exclusions>
<exclusion>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
</exclusion>
</exclusions>
</dependency>

<!-- Testing and Mocking -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
Expand Down
8 changes: 7 additions & 1 deletion uberjar/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,12 @@
<artifactId>openshift-server-mock</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>io.fabric8</groupId>
<artifactId>zjsonpatch</artifactId>
<version>${project.version}</version>
</dependency>

<!-- Legal Transitives -->
<dependency>
Expand Down Expand Up @@ -233,7 +239,7 @@
</dependency>

<dependency>
<groupId>io.fabric8</groupId>
<groupId>com.flipkart.zjsonpatch</groupId>
<artifactId>zjsonpatch</artifactId>
<version>${zjsonpatch.version}</version>
</dependency>
Expand Down
97 changes: 97 additions & 0 deletions zjsonpatch/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (C) 2015 Red Hat, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-client-project</artifactId>
<version>7.0-SNAPSHOT</version>
</parent>

<packaging>bundle</packaging>
<artifactId>zjsonpatch</artifactId>

<properties>
<osgi.import>
*
</osgi.import>
<osgi.export>
io.fabric8.zjsonpatch*,
com.flipkart.zjsonpatch,
</osgi.export>
</properties>

<dependencies>
<dependency>
<groupId>com.flipkart.zjsonpatch</groupId>
<artifactId>zjsonpatch</artifactId>
<version>${zjsonpatch.version}</version>
<exclusions>
<exclusion>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<executions>
<execution>
<id>bundle</id>
<phase>package</phase>
<goals>
<goal>bundle</goal>
</goals>
<configuration>
<instructions>
<Bundle-Name>${project.name}</Bundle-Name>
<Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
<Export-Package>${osgi.export}</Export-Package>
<Import-Package>${osgi.import}</Import-Package>
<DynamicImport-Package>${osgi.dynamic.import}</DynamicImport-Package>
<Private-Package>${osgi.private}</Private-Package>
<Require-Bundle>${osgi.bundles}</Require-Bundle>
<Bundle-Activator>${osgi.activator}</Bundle-Activator>
<Export-Service>${osgi.export.service}</Export-Service>
</instructions>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
82 changes: 82 additions & 0 deletions zjsonpatch/src/main/java/io/fabric8/zjsonpatch/Diff.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
* Copyright (C) 2015 Red Hat, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.fabric8.zjsonpatch;

import com.fasterxml.jackson.databind.JsonNode;
import com.flipkart.zjsonpatch.Operation;

/**
* This class is ported from <a href=
* "https://github.com/flipkart-incubator/zjsonpatch/blob/a446bf598231c06006d4e3df69b846cdb16d8889/src/main/java/com/flipkart/zjsonpatch/Diff.java#L25">FlipKart
* JSONPatch repository</a>
*/
class Diff {
private final Operation operation;
private final JsonPointer path;
private final JsonNode value;
private JsonPointer toPath; //only to be used in move operation
private final JsonNode srcValue; // only used in replace operation

Diff(Operation operation, JsonPointer path, JsonNode value) {
this.operation = operation;
this.path = path;
this.value = value;
this.srcValue = null;
}

Diff(Operation operation, JsonPointer fromPath, JsonPointer toPath) {
this.operation = operation;
this.path = fromPath;
this.toPath = toPath;
this.value = null;
this.srcValue = null;
}

Diff(Operation operation, JsonPointer path, JsonNode srcValue, JsonNode value) {
this.operation = operation;
this.path = path;
this.value = value;
this.srcValue = srcValue;
}

public Operation getOperation() {
return operation;
}

public JsonPointer getPath() {
return path;
}

public JsonNode getValue() {
return value;
}

public static Diff generateDiff(Operation replace, JsonPointer path, JsonNode target) {
return new Diff(replace, path, target);
}

public static Diff generateDiff(Operation replace, JsonPointer path, JsonNode source, JsonNode target) {
return new Diff(replace, path, source, target);
}

JsonPointer getToPath() {
return toPath;
}

public JsonNode getSrcValue() {
return srcValue;
}
}
Loading

0 comments on commit 848e90f

Please sign in to comment.