Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(zjsonpatch): move io.fabric8:zjsonpatch as a module in Fabric8 kubernetes Client #6276

Merged
merged 2 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* Fix #6008: removing the optional dependency on bouncy castle
* Fix #6230: introduced Quantity.multiply(int) to allow for Quantity multiplication by an integer
* Fix #6281: use GitHub binary repo for Kube API Tests
* Fix #5480: Move `io.fabric8:zjsonpatch` to KubernetesClient project

#### Dependency Upgrade
* Fix #6052: Removed dependency on no longer maintained com.github.mifmif:generex
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
14 changes: 7 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@
<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>
<jandex.version>3.2.2</jandex.version>

<!-- API versions -->
Expand Down Expand Up @@ -205,6 +204,7 @@
</properties>
<modules>
<module>kubernetes-model-generator</module>
<module>zjsonpatch</module>
<module>kubernetes-client-api</module>
<module>kubernetes-client</module>
<module>junit/mockwebserver</module>
Expand All @@ -215,7 +215,6 @@
<module>openshift-client</module>
<module>extensions</module>
<module>junit/openshift-server-mock</module>
<module>kubernetes-examples</module>
<module>platforms</module>
<module>kubernetes-tests</module>
<module>uberjar</module>
Expand All @@ -226,6 +225,7 @@
<module>httpclient-vertx</module>
<module>kubernetes-client-deps-compatibility-tests</module>
<module>log4j</module>
<module>kubernetes-examples</module>
</modules>

<dependencyManagement>
Expand Down Expand Up @@ -720,6 +720,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 @@ -901,11 +906,6 @@
</dependency>

<!-- Testing and Mocking -->
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>zjsonpatch</artifactId>
<version>${zjsonpatch.version}</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
Expand Down
12 changes: 6 additions & 6 deletions uberjar/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,12 @@
<version>${project.version}</version>
</dependency>

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

<!-- Legal Transitives -->
<dependency>
<groupId>com.squareup.okhttp3</groupId>
Expand Down Expand Up @@ -232,12 +238,6 @@
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>

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

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
Expand Down
95 changes: 95 additions & 0 deletions zjsonpatch/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<?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>
com.fasterxml.jackson.*,
io.fabric8.zjsonpatch.internal.collections4
</osgi.import>
<osgi.export>
io.fabric8.zjsonpatch*,
</osgi.export>
</properties>

<dependencies>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</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>
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* 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 java.util.EnumSet;

/**
* This class is ported from <a href=
* "https://github.com/flipkart-incubator/zjsonpatch/blob/a446bf598231c06006d4e3df69b846cdb16d8889/src/main/java/com/flipkart/zjsonpatch/CompatibilityFlags.java">FlipKart
* zjsonpatch repository</a>
*/
public enum CompatibilityFlags {
MISSING_VALUES_AS_NULLS,
REMOVE_NONE_EXISTING_ARRAY_ELEMENT,
ALLOW_MISSING_TARGET_OBJECT_ON_REPLACE,
FORBID_REMOVE_MISSING_OBJECT;

public static EnumSet<CompatibilityFlags> defaults() {
return EnumSet.noneOf(CompatibilityFlags.class);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* 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 java.util.EnumSet;

/**
* This class is ported from <a href=
* "https://github.com/flipkart-incubator/zjsonpatch/blob/a446bf598231c06006d4e3df69b846cdb16d8889/src/main/java/com/flipkart/zjsonpatch/CopyingApplyProcessor.java">FlipKart
* zjsonpatch repository</a>
*/

class CopyingApplyProcessor extends InPlaceApplyProcessor {

CopyingApplyProcessor(JsonNode target, EnumSet<CompatibilityFlags> flags) {
super(target.deepCopy(), flags);
}
}
81 changes: 81 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,81 @@
/*
* 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;

/**
* This class is ported from <a href=
* "https://github.com/flipkart-incubator/zjsonpatch/blob/a446bf598231c06006d4e3df69b846cdb16d8889/src/main/java/com/flipkart/zjsonpatch/Diff.java">FlipKart
* zjsonpatch 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
Loading