-
Notifications
You must be signed in to change notification settings - Fork 5
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
major refactor #519
Conversation
} | ||
|
||
// This is a modified copy of resource.Builder's mappingFor method. | ||
func (r *ResourceRepo) mappingFor(resourceOrKindArg string) (*meta.RESTMapping, error) { |
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.
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) { |
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.
exported method ResourceRepo.Objects should have comment or be unexported
return m["creationTimestamp"] | ||
} | ||
|
||
func (u Object) Unstructured() *unstructured.Unstructured { |
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.
exported method Object.Unstructured should have comment or be unexported
return &unstructured.Unstructured{Object: u} | ||
} | ||
|
||
type Objects []Object |
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.
exported type Objects should have comment or be unexported
} | ||
|
||
func NewResourceRepo(factory util.Factory) ResourceRepo { | ||
type Object map[string]interface{} |
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.
exported type Object should have comment or be unexported
Code Climate has analyzed commit 1e84d75 and detected 17 issues on this pull request. Here's the issue category breakdown:
View more on Code Climate. |
return unstructuredObjects, err | ||
} | ||
|
||
func (r *ResourceRepo) Owners(obj Object) (out Objects, err error) { |
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.
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) { |
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.
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) { |
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.
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) { |
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.
Similar blocks of code found in 3 locations. Consider refactoring.
pkg/input/input.go
Outdated
|
||
return ResourceRepo{ | ||
func NewResourceRepo(factory util.Factory) *ResourceRepo { |
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.
exported function NewResourceRepo should have comment or be unexported
|
||
return ResourceRepo{ | ||
f: factory, | ||
func NewResourceRepo(factory util.Factory) (*ResourceRepo, error) { |
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.
exported function NewResourceRepo should have comment or be unexported
return unstructuredObjects, err | ||
} | ||
|
||
func (r *ResourceRepo) Owners(obj Object) (out Objects, err error) { |
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.
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) { |
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.
exported method ResourceRepo.FirstObject should have comment or be unexported
return objects[0], err | ||
} | ||
|
||
func (r *ResourceRepo) ObjectEvents(u *unstructured.Unstructured) (*corev1.EventList, error) { |
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.
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) { |
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.
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) { |
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.
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) { |
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.
exported method ResourceRepo.GVRFor should have comment or be unexported
return mapping, nil | ||
} | ||
|
||
func (r *ResourceRepo) Ingresses(namespace string) (*netv1.IngressList, error) { |
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.
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) { |
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.
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) { |
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.
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) { |
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.
exported method ResourceRepo.Endpoints should have comment or be unexported
return nodeStatsSummary, err | ||
} | ||
|
||
func (r *ResourceRepo) NonTerminatedPodsOnTheNode(nodeName string) (Objects, error) { |
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.
exported method ResourceRepo.NonTerminatedPodsOnTheNode should have comment or be unexported
No description provided.