-
Notifications
You must be signed in to change notification settings - Fork 555
fix: Port number fix in helm app #3843
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
Conversation
| }, | ||
| } | ||
| clusterIdString := strconv.Itoa(clusterId) | ||
| validRequest := impl.k8sCommonService.FilterK8sResources(rctx, resourceTree, validRequests, k8sAppDetail, clusterIdString, []string{k8s.ServiceKind, k8s.EndpointsKind, k8s.IngressKind}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for every usage of FilterK8sResources, we are passing validRequests as empty array...need to remove this to clean signature with irrelevant argument
pkg/k8s/K8sCommonService.go
Outdated
| if portHolder.ManifestResponse == nil { | ||
| continue | ||
| } | ||
| kind, ok := portHolder.ManifestResponse.Manifest.Object["kind"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extract/use constant for "kind"
pkg/k8s/K8sCommonService.go
Outdated
| return resourceTree, nil | ||
| } | ||
| if kind == ServiceKind { | ||
| specField, ok := portHolder.ManifestResponse.Manifest.Object["spec"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extract/use constant for "spec"
pkg/k8s/K8sCommonService.go
Outdated
| } | ||
| spec := specField.(map[string]interface{}) | ||
| if spec != nil { | ||
| ports, ok := spec["ports"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extract/use constant for "ports"
pkg/k8s/K8sCommonService.go
Outdated
| } | ||
| } | ||
| if kind == EndpointsKind { | ||
| subsetsField, ok := portHolder.ManifestResponse.Manifest.Object["subsets"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extract/use constant for "subsets"
pkg/k8s/K8sCommonService.go
Outdated
| portList := ports.([]interface{}) | ||
| for _, portItem := range portList { | ||
| if portItem.(map[string]interface{}) != nil { | ||
| portNumbers := portItem.(map[string]interface{})["port"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's add ok bool validation for every type assertion. example -
portNumbers := portItem.(map[string]interface{})["port"] --> portNumbers, ok := portItem.(map[string]interface{})["port"]
pkg/k8s/K8sCommonService.go
Outdated
| } | ||
| } | ||
| } else { | ||
| impl.logger.Errorw("spec doest not contain data", "err", spec) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not returning here? also, key value pair is wrong...given spec printing err
pkg/k8s/K8sCommonService.go
Outdated
| if kind == EndpointsKind { | ||
| subsetsField, ok := portHolder.ManifestResponse.Manifest.Object["subsets"] | ||
| if !ok { | ||
| impl.logger.Errorw("spec not found in resource tree, unable to extract port no") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not looks like error, can be warn or info
pkg/k8s/K8sCommonService.go
Outdated
| if subsetObj != nil { | ||
| ports, ok := subsetObj["ports"] | ||
| if !ok { | ||
| impl.logger.Errorw("ports not found in resource tree endpoints, unable to extract port no") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
incorrect level of log
pkg/k8s/K8sCommonService.go
Outdated
| if kind == "EndpointSlice" { | ||
| portsField, ok := portHolder.ManifestResponse.Manifest.Object["ports"] | ||
| if !ok { | ||
| impl.logger.Errorw("ports not found in resource tree endpoint, unable to extract port no") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
incorrect level of log
|
Kudos, SonarCloud Quality Gate passed!
|








Description
Fixes #3829
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Checklist:
Does this PR introduce a user-facing change?