eclipse-jkube / jkube

Build and Deploy java applications on Kubernetes
https://www.eclipse.dev/jkube/
Eclipse Public License 2.0
775 stars 523 forks source link

FileSecretIT is failing on windows #3478

Open rohanKanojia opened 1 month ago

rohanKanojia commented 1 month ago

Component

None

Task description

Description

Related to #3406

⚠️ A windows machine is required to reproduce and fix problems in this issue

FileSecretIT is failing on windows:

Error:    FileSecretIT.k8sResource_whenRun_generatesK8sSecret:35 � IllegalArgument Values not equal for entry: 'application.properties', expected 'a2V5MSA9IHZhbHVlMQprZXkyID0gdmFsdWUyCmtleTMgPSB2YWx1ZTM=' but was 'a2V5MSA9IHZhbHVlMQ0Ka2V5MiA9IHZhbHVlMg0Ka2V5MyA9IHZhbHVlMw=='
Error:    FileSecretIT.ocResource_whenRun_generatesK8sSecret:48 � IllegalArgument Values not equal for entry: 'application.properties', expected 'a2V5MSA9IHZhbHVlMQprZXkyID0gdmFsdWUyCmtleTMgPSB2YWx1ZTM=' but was 'a2V5MSA9IHZhbHVlMQ0Ka2V5MiA9IHZhbHVlMg0Ka2V5MyA9IHZhbHVlMw=='

This issue looks related to one issue I had fixed https://github.com/eclipse-jkube/jkube/pull/3014

Problem seems to be here : https://github.com/eclipse-jkube/jkube/blob/78e8631c9c101e52dc94f14fb97c16383396afc5/jkube-kit/enricher/generic/src/main/java/org/eclipse/jkube/enricher/generic/FileDataSecretEnricher.java#L87-L89

Jackson generates annotation with platform specific line delimiters /r/n for windows.

If we change it like this, it makes test pass:

-        return Files.readAllBytes(Paths.get(location));
+        String data = new String(Files.readAllBytes(Paths.get(location)));
+        data = data.replaceAll("\r?\n", "\n");
+        return data.getBytes();

Expected Behavior

FileSecretIT should pass on windows

Acceptance Criteria

pujakarakoti07 commented 1 month ago

@rohanKanojia I want to work on this issue, can you please assign this to me?