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

major refactor #519

Merged
merged 17 commits into from
Oct 23, 2024
Merged

major refactor #519

merged 17 commits into from
Oct 23, 2024

Conversation

bergerx
Copy link
Owner

@bergerx bergerx commented Aug 9, 2024

No description provided.

}

// This is a modified copy of resource.Builder's mappingFor method.
func (r *ResourceRepo) mappingFor(resourceOrKindArg string) (*meta.RESTMapping, error) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Method ResourceRepo.mappingFor has 6 return statements (exceeds 4 allowed).

@@ -57,22 +93,127 @@
return builder.Do()
}

func (r *ResourceRepo) ResourceInfos(namespace string, args []string, labelSelector string) ([]*resource.Info, error) {
func (r *ResourceRepo) Objects(namespace string, args []string, labelSelector string) (Objects, error) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exported method ResourceRepo.Objects should have comment or be unexported

return m["creationTimestamp"]
}

func (u Object) Unstructured() *unstructured.Unstructured {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exported method Object.Unstructured should have comment or be unexported

return &unstructured.Unstructured{Object: u}
}

type Objects []Object
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exported type Objects should have comment or be unexported

}

func NewResourceRepo(factory util.Factory) ResourceRepo {
type Object map[string]interface{}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exported type Object should have comment or be unexported

Copy link

codeclimate bot commented Aug 9, 2024

Code Climate has analyzed commit 1e84d75 and detected 17 issues on this pull request.

Here's the issue category breakdown:

Category Count
Complexity 2
Style 15

View more on Code Climate.

return unstructuredObjects, err
}

func (r *ResourceRepo) Owners(obj Object) (out Objects, err error) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Method ResourceRepo.Owners has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.

return mapping, nil
}

func (r *ResourceRepo) Ingresses(namespace string) (*netv1.IngressList, error) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 3 locations. Consider refactoring.

return clientSet.NetworkingV1().Ingresses(namespace).List(context.TODO(), metav1.ListOptions{})
}

func (r *ResourceRepo) Services(namespace string) (*corev1.ServiceList, error) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 3 locations. Consider refactoring.

return clientSet.CoreV1().Services(namespace).Get(context.TODO(), name, metav1.GetOptions{})
}

func (r *ResourceRepo) Endpoints(namespace string) (*corev1.EndpointsList, error) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 3 locations. Consider refactoring.


return ResourceRepo{
func NewResourceRepo(factory util.Factory) *ResourceRepo {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exported function NewResourceRepo should have comment or be unexported


return ResourceRepo{
f: factory,
func NewResourceRepo(factory util.Factory) (*ResourceRepo, error) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exported function NewResourceRepo should have comment or be unexported

return unstructuredObjects, err
}

func (r *ResourceRepo) Owners(obj Object) (out Objects, err error) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exported method ResourceRepo.Owners should have comment or be unexported

return out, nil
}

func (r *ResourceRepo) FirstObject(namespace string, args []string, labelSelector string) (Object, error) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exported method ResourceRepo.FirstObject should have comment or be unexported

return objects[0], err
}

func (r *ResourceRepo) ObjectEvents(u *unstructured.Unstructured) (*corev1.EventList, error) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exported method ResourceRepo.ObjectEvents should have comment or be unexported

}

func (r *ResourceRepo) ToRESTMapper() (meta.RESTMapper, error) {
return r.f.ToRESTMapper()
func (r *ResourceRepo) DynamicObject(gvr schema.GroupVersionResource, namespace string, name string) (Object, error) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exported method ResourceRepo.DynamicObject should have comment or be unexported

}

func (r *ResourceRepo) KubernetesClientSet() (*kubernetes.Clientset, error) {
return r.f.KubernetesClientSet()
func (r *ResourceRepo) DynamicObjects(gvr schema.GroupVersionResource, namespace string) (Objects, error) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exported method ResourceRepo.DynamicObjects should have comment or be unexported

}

func (r *ResourceRepo) DynamicClient() (dynamic.Interface, error) {
return r.f.DynamicClient()
func (r *ResourceRepo) GVRFor(resourceOrKindArg string) (schema.GroupVersionResource, error) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exported method ResourceRepo.GVRFor should have comment or be unexported

return mapping, nil
}

func (r *ResourceRepo) Ingresses(namespace string) (*netv1.IngressList, error) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exported method ResourceRepo.Ingresses should have comment or be unexported

return r.kubernetesClientSet.NetworkingV1().Ingresses(namespace).List(context.TODO(), metav1.ListOptions{})
}

func (r *ResourceRepo) Services(namespace string) (*corev1.ServiceList, error) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exported method ResourceRepo.Services should have comment or be unexported

return r.kubernetesClientSet.CoreV1().Services(namespace).List(context.TODO(), metav1.ListOptions{})
}

func (r *ResourceRepo) Service(namespace, name string) (*corev1.Service, error) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exported method ResourceRepo.Service should have comment or be unexported

return r.kubernetesClientSet.CoreV1().Services(namespace).Get(context.TODO(), name, metav1.GetOptions{})
}

func (r *ResourceRepo) Endpoints(namespace string) (*corev1.EndpointsList, error) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exported method ResourceRepo.Endpoints should have comment or be unexported

return nodeStatsSummary, err
}

func (r *ResourceRepo) NonTerminatedPodsOnTheNode(nodeName string) (Objects, error) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exported method ResourceRepo.NonTerminatedPodsOnTheNode should have comment or be unexported

@bergerx bergerx merged commit 1e84d75 into master Oct 23, 2024
2 of 4 checks passed
@bergerx bergerx deleted the code-re-org branch October 23, 2024 23:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant