diff --git a/pkg/kube/kube.go b/pkg/kube/kube.go index 8d28431..6198cd5 100644 --- a/pkg/kube/kube.go +++ b/pkg/kube/kube.go @@ -32,6 +32,15 @@ import ( "k8s.io/client-go/tools/clientcmd" ) +// TODO: write down the design of Kubedog: why pkgs are how they are, methods names and the use of correct verbs, +// how kube is broken into multiple pkgs and then used from there in a sort-of-like a divide-and-conquer manner +// to keep methods with a single functionality and not use inputs to change their behavior, instead create one function per +// behavior. In this manner we have the syntax ( which will make us want to have functions change their behavior based on +// the input) then we use kube to use behavior-changing inputs to call different functions with specific behaviors or functions +// in a different manner. + +// TODO: add a gif animation of how to use kubedog like some open source projects do + type ClientSet struct { KubeInterface kubernetes.Interface DynamicInterface dynamic.Interface @@ -130,6 +139,7 @@ func (kc *ClientSet) ResourceOperation(operation, resourceFileName string) error if err != nil { return err } + // TODO: use ResourceOperationInNamespace should like ResourceOperation does, ResourceOperation is redundant return unstruct.ResourceOperation(kc.DynamicInterface, resource, operation) } @@ -210,6 +220,7 @@ func (kc *ClientSet) VerifyInstanceGroups() error { } func (kc *ClientSet) ListPods(namespace string) error { + // TODO: use ListPodsWithSelector like ListPods does, ListPods is redundant return pod.ListPods(kc.KubeInterface, namespace) } @@ -226,6 +237,7 @@ func (kc *ClientSet) SomeOrAllPodsInNamespaceWithSelectorHaveStringInLogsSinceTi if err != nil { return err } + // TODO: refactor SomeOrAllPodsInNamespaceWithSelectorHaveStringInLogsSinceTime to not have the input someOrAll change its behavior, instead have different methods return pod.SomeOrAllPodsInNamespaceWithSelectorHaveStringInLogsSinceTime(kc.KubeInterface, kc.getExpBackoff(), someOrAll, namespace, selector, searchKeyword, timestamp) } @@ -266,6 +278,7 @@ func (kc *ClientSet) SecretOperationFromEnvironmentVariable(operation, name, nam } func (kc *ClientSet) SecretDelete(name, namespace string) error { + // TODO: use SecretOperationFromEnvironmentVariable directly like SecretDelete does, SecretDelete is redundant return structured.SecretDelete(kc.KubeInterface, name, namespace) } @@ -278,6 +291,7 @@ func (kc *ClientSet) ResourceInNamespace(resourceType, name, isOrIsNot, namespac case "is": return structured.ResourceInNamespace(kc.KubeInterface, resourceType, name, namespace) case "is not": + // TODO: is this redundant too? call ResourceInNamespace like ResourceNotInNamespace does? return structured.ResourceNotInNamespace(kc.KubeInterface, resourceType, name, namespace) default: return errors.Errorf("paramter isOrIsNot can only be 'is' or 'is not'") diff --git a/pkg/kube/pod/pod.go b/pkg/kube/pod/pod.go index faaa342..f1feb08 100644 --- a/pkg/kube/pod/pod.go +++ b/pkg/kube/pod/pod.go @@ -30,6 +30,22 @@ import ( "k8s.io/client-go/kubernetes" ) +// TODO: unit test for this package + +/* +// TODO: should the verb be list? + +Other functions for pods have no verb and list sounds like a verb that should not failed if nothing was found? + +// TODO: look at all the other functions names, make sure to find a way to make things concistant with their names and verbs + +We dont want to make breaking changes again, the code within the functions is easy to change without breaking things +but the name is a breaking changes and it should make sense to set the library standard + +I am thinking functions that do not return should not be Get but List, now in the syntax it can and should be Get even tho it lists +to be consistant with kubectl (get lists and fails if not found, list can just list whats there with no fail). +If we make things that list be named Get here in code it will get confused with the functions that actually Get things and return +*/ func ListPods(kubeClientset kubernetes.Interface, namespace string) error { return ListPodsWithSelector(kubeClientset, namespace, "") } diff --git a/pkg/kube/unstructured/unstructured.go b/pkg/kube/unstructured/unstructured.go index d374b6a..8c928f7 100644 --- a/pkg/kube/unstructured/unstructured.go +++ b/pkg/kube/unstructured/unstructured.go @@ -338,6 +338,7 @@ func UpdateResourceWithField(dynamicClient dynamic.Interface, resource unstructu return nil } +// TODO: refactor so it doesnt need the dynamic and discovery clients func DeleteResourcesAtPath(dynamicClient dynamic.Interface, dc discovery.DiscoveryInterface, TemplateArguments interface{}, w common.WaiterConfig, resourcesPath string) error { if err := validateDynamicClient(dynamicClient); err != nil { return err