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
+ Keep `io.fabric8.zjsonpatch.JsonDiff` class as a wrapper around
  `com.flipkart.zjsonpatch.JsonDiff`

Signed-off-by: Rohan Kumar <[email protected]>
  • Loading branch information
rohanKanojia committed Aug 16, 2024
1 parent 342fb8a commit ef75950
Show file tree
Hide file tree
Showing 25 changed files with 1,138 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,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
7 changes: 7 additions & 0 deletions doc/MIGRATION-v7.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Contents
- [Bouncy Castle is no longer needed](#bouncy-castle)
- [Fabric8 ZJsonpatch Dependency no longer used](#fabric8-zjsonpatch-dependency)
- [Model Changes](#model-changes)
- [kubernetes-model artifact removed](#kubernetes-model-artifact-removed)
- [Deprecations and Removals](#deprecations-and-removals)
Expand All @@ -20,6 +21,12 @@ The Bouncy Castle library is no longer needed as a dependency.
In previous versions, this was an optional dependency needed for Elliptic Curve (EC) Keys.
The Kubernetes client now uses the default Java security provider which should be enough to handle all scenarios.

## Fabric8 ZJsonpatch Dependency no longer used <a href="#fabric8-zjsonpatch-dependency" id="fabric8-zjsonpatch-dependency" />

We are no longer using outdated [`io.fabric8:zjsonpatch`](https://central.sonatype.com/artifact/io.fabric8/zjsonpatch/versions) dependency.
We're directly relying on [`com.flipkart.zjsonpatch`](https://central.sonatype.com/artifact/com.flipkart.zjsonpatch/zjsonpatch/versions) dependency instead.
If you're using `io.fabric8.zjsonpatch` classes in your code, you would need to change the imports to use [`com.flipkart.zjsonpatch`](https://central.sonatype.com/artifact/com.flipkart.zjsonpatch/zjsonpatch/versions) instead.

## Model Changes <a href="#model-changes" id="model-changes"/>

### kubernetes-model artifact removed <a href="#kubernetes-model-artifact-removed" id="kubernetes-model-artifact-removed"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator;
import com.flipkart.zjsonpatch.JsonDiff;
import com.flipkart.zjsonpatch.JsonPatch;
import com.github.difflib.text.DiffRow;
import com.github.difflib.text.DiffRowGenerator;
import io.fabric8.zjsonpatch.JsonDiff;
import io.fabric8.zjsonpatch.JsonPatch;

import java.nio.charset.StandardCharsets;
import java.util.Arrays;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectReader;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.flipkart.zjsonpatch.JsonDiff;
import io.fabric8.kubernetes.api.model.GenericKubernetesResource;
import io.fabric8.kubernetes.client.server.mock.Resetable;
import io.fabric8.kubernetes.client.utils.Serialization;
import io.fabric8.mockwebserver.crud.AttributeSet;
import io.fabric8.zjsonpatch.JsonDiff;

import java.util.Map;
import java.util.Optional;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.flipkart.zjsonpatch.JsonPatch;
import io.fabric8.kubernetes.api.model.GenericKubernetesResource;
import io.fabric8.kubernetes.client.dsl.base.PatchType;
import io.fabric8.kubernetes.client.utils.Serialization;
import io.fabric8.kubernetes.client.utils.Utils;
import io.fabric8.mockwebserver.crud.AttributeSet;
import io.fabric8.zjsonpatch.JsonPatch;
import okhttp3.MediaType;
import okhttp3.mockwebserver.MockResponse;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
package io.fabric8.mockwebserver.crud;

import com.fasterxml.jackson.databind.JsonNode;
import com.flipkart.zjsonpatch.JsonPatch;
import io.fabric8.mockwebserver.Context;
import io.fabric8.mockwebserver.MockServerException;
import io.fabric8.zjsonpatch.JsonPatch;
import okhttp3.mockwebserver.Dispatcher;
import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.RecordedRequest;
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
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.flipkart.zjsonpatch.JsonDiff;
import io.fabric8.kubernetes.client.utils.KubernetesSerialization;
import io.fabric8.zjsonpatch.JsonDiff;

import java.util.ArrayList;
import java.util.Iterator;
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 @@ -37,7 +37,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
20 changes: 16 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
<maven-core.version>3.9.8</maven-core.version>
<maven-plugin-annotations.version>3.13.1</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 @@ -882,13 +888,19 @@
<artifactId>okio</artifactId>
<version>${okio.version}</version>
</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
98 changes: 98 additions & 0 deletions zjsonpatch/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<?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,
org.apache.commons.collections4*
</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>
27 changes: 27 additions & 0 deletions zjsonpatch/src/main/java/io/fabric8/zjsonpatch/JsonDiff.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* 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;

public class JsonDiff {
private JsonDiff() {
}

public static JsonNode asJson(final JsonNode source, final JsonNode target) {
return com.flipkart.zjsonpatch.JsonDiff.asJson(source, target);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
* 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 org.apache.commons.collections4;

import java.io.Serializable;

/**
* Ported from <a href=
* "https://github.com/apache/commons-collections/blob/master/src/main/java/org/apache/commons/collections4/functors/DefaultEquator.java">Apache
* Commons Collections</a>
*/
public class DefaultEquator<T> implements Equator<T>, Serializable {

/**
* Static instance
*/
@SuppressWarnings("rawtypes") // the static instance works for all types
public static final DefaultEquator INSTANCE = new DefaultEquator<Object>();
/**
* Hashcode used for <code>null</code> objects.
*/
public static final int HASHCODE_NULL = -1;
/**
* Serial version UID
*/
private static final long serialVersionUID = 825802648423525485L;

/**
* Restricted constructor.
*/
private DefaultEquator() {
super();
}

/**
* Factory returning the typed singleton instance.
*
* @param <T> the object type
* @return the singleton instance
*/
@SuppressWarnings("unchecked") // the static instance works for all types
public static <T> DefaultEquator<T> defaultEquator() {
return (DefaultEquator<T>) DefaultEquator.INSTANCE;
}

/**
* {@inheritDoc} Delegates to {@link Object#equals(Object)}.
*/
public boolean equate(final T o1, final T o2) {
return o1 == o2 || o1 != null && o1.equals(o2);
}

/**
* {@inheritDoc}
*
* @return <code>o.hashCode()</code> if <code>o</code> is non-
* <code>null</code>, else {@link #HASHCODE_NULL}.
*/
public int hash(final T o) {
return o == null ? HASHCODE_NULL : o.hashCode();
}

private Object readResolve() {
return INSTANCE;
}

}
Loading

0 comments on commit ef75950

Please sign in to comment.