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

GitEnricher : Return empty map instead of returning null #2710

Closed
2 tasks done
rohanKanojia opened this issue Feb 21, 2024 · 1 comment · Fixed by #2723
Closed
2 tasks done

GitEnricher : Return empty map instead of returning null #2710

rohanKanojia opened this issue Feb 21, 2024 · 1 comment · Fixed by #2723
Assignees
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@rohanKanojia
Copy link
Member

rohanKanojia commented Feb 21, 2024

Component

JKube Kit

Task description

Description

GitEnricher has this getAnnotations method that returns a map of annotations containing Git related information of the project:

https://github.com/eclipse/jkube/blob/fddd604457c98a197bd8b2f3cbb3167dde2a9b3d/jkube-kit/enricher/generic/src/main/java/org/eclipse/jkube/enricher/generic/GitEnricher.java#L53-L67

It's initializing org.eclipse.jgit.lib.Repository object in try with resources block and catching the exception thrown in catch block. However, it returns a null value when the exception is caught.

https://github.com/eclipse/jkube/blob/fddd604457c98a197bd8b2f3cbb3167dde2a9b3d/jkube-kit/enricher/generic/src/main/java/org/eclipse/jkube/enricher/generic/GitEnricher.java#L66

We should be returning an empty map instead of null. We should remove this line as we're already returning Map annotations created in the beginning of the function at the end of method.

Expected Behavior

return null` line is removed from the method

Acceptance Criteria

  • line 66 containing return null statement is removed
  • GitEnricherTest should pass after making this change

How to manually test my changes

Kubernetes

If you don't have a real Kubernetes cluster available (most probably), you can use Minikube or Kind to test with a local cluster.

OpenShift

If you don't have a real OpenShift cluster available (most probably), you can use Red Hat's developer Sandbox for Red Hat OpenShift. The only requirement is to have a Red Hat account.

Once you have your Sandbox environment, you'll need to download the oc tool from the cluster console.
(Press the ? icon and from the context menu select Command line tools, you'll be redirected to https://$subdomain.openshiftapps.com/command-lines-tools where you'll be able to download the CLI for your platform)

@ajayl83
Copy link
Contributor

ajayl83 commented Feb 22, 2024

@rohanKanojia can i pick it up? already returning Map annotations created in the beginning of the function at the end of metho-> Collections.emptyMap() is better option rather here!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
2 participants