Repository: FairwindsOps/pluto
Pull request #516 (2023-11-08 15:30:14)

Fixing isReplacementAvailableIn logic when field available in is empty
This PR fixes #

## Checklist
* [x] I have signed the CLA
* [x] I have updated/added any relevant documentation

## Description
### What's the goal of this PR?
Fixing logic for isReplacementAvailableIn  when field availableIn is empty
### What changes did you make?
Updated isReplacementAvailableIn  function
### What alternative solution should we consider, if any?



CLAassistant: [![CLA assistant check](https://cla-assistant.io/pull/badge/not_signed)](https://cla-assistant.io/FairwindsOps/pluto?pullRequest=516) <br/>Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our [Contributor License Agreement](https://cla-assistant.io/FairwindsOps/pluto?pullRequest=516) before we can accept your contribution.<br/><sub>You have signed the CLA already but the status is still pending? Let us [recheck](https://cla-assistant.io/check/FairwindsOps/pluto?pullRequest=516) it.</sub>
fairwinds-insights[bot]: ## Fairwinds Insights CI Report
> [View the Full Report](https://insights.fairwinds.com/gh/FairwindsOps/pluto/js%2FReplacementAvailable)

:white_check_mark: No new Action Items detected!
rbren: @jdesouza can you fill out the PR template?

Patch:
diff --git a/pkg/api/versions.go b/pkg/api/versions.go
index 8bbd487..0eb7b61 100644
--- a/pkg/api/versions.go
+++ b/pkg/api/versions.go
@@ -253,7 +253,7 @@ func (v *Version) isReplacementAvailableIn(targetVersions map[string]string) boo
 	}
 
 	if v.ReplacementAvailableIn == "" {
-		return true
+		return false
 	}
 
 	targetVersion, ok := targetVersions[v.Component]


Test patch:
diff --git a/pkg/api/output_test.go b/pkg/api/output_test.go
index 9a46241..c0bad7e 100644
--- a/pkg/api/output_test.go
+++ b/pkg/api/output_test.go
@@ -84,6 +84,7 @@ var testOutputDeprecatedNotRemoved = &Output{
 		ReplacementAPI: "none",
 		Component:      "foo",
 	},
+	ReplacementAvailable: false,
 }
 
 func init() {
@@ -109,7 +110,7 @@ func ExampleInstance_DisplayOutput_normal() {
 	// NAME-------------------- KIND-------- VERSION------------- REPLACEMENT-- REMOVED-- DEPRECATED-- REPL AVAIL--
 	// some name one----------- Deployment-- extensions/v1beta1-- apps/v1------ true----- true-------- true--------
 	// some name two----------- Deployment-- extensions/v1beta1-- apps/v1------ true----- true-------- true--------
-	// deprecated not removed-- Deployment-- apps/v1------------- none--------- false---- true-------- true--------
+	// deprecated not removed-- Deployment-- apps/v1------------- none--------- false---- true-------- false-------
 }
 
 func ExampleInstance_DisplayOutput_onlyShowRemoved() {
@@ -411,7 +412,7 @@ func TestGetReturnCode(t *testing.T) {
 				ignoreRemovals:               false,
 				ignoreReplacementUnavailable: false,
 			},
-			want: 2,
+			want: 4,
 		},
 		{
 			name: "version is deprecated ignore deprecations",
@@ -429,7 +430,7 @@ func TestGetReturnCode(t *testing.T) {
 				ignoreRemovals:               false,
 				ignoreReplacementUnavailable: false,
 			},
-			want: 0,
+			want: 4,
 		},
 		{
 			name: "version is removed",
@@ -447,7 +448,7 @@ func TestGetReturnCode(t *testing.T) {
 				ignoreRemovals:               false,
 				ignoreReplacementUnavailable: false,
 			},
-			want: 3,
+			want: 4,
 		},
 		{
 			name: "version is removed and replacement is unavailable",
diff --git a/pkg/api/versions_test.go b/pkg/api/versions_test.go
index f84a4d5..1c33a2f 100644
--- a/pkg/api/versions_test.go
+++ b/pkg/api/versions_test.go
@@ -467,7 +467,7 @@ func TestVersion_isReplacementAvailableIn(t *testing.T) {
 			targetVersions:         map[string]string{"foo": "v1.16.0"},
 			component:              "foo",
 			replacementAvailableIn: "",
-			want:                   true,
+			want:                   false,
 		},
 		{
 			name:                   "targetVersions not included for component",