Skip to content

Commit

Permalink
adding TODOs
Browse files Browse the repository at this point in the history
Signed-off-by: Alfredo Garo <garomonegro@Alfredos-MacBook-Pro.local>
  • Loading branch information
Alfredo Garo authored and Alfredo Garo committed Jul 24, 2023
1 parent 418736d commit a0061ca
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
14 changes: 14 additions & 0 deletions pkg/kube/kube.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}

Expand Down Expand Up @@ -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)
}

Expand All @@ -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)
}

Expand Down Expand Up @@ -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)
}

Expand All @@ -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'")
Expand Down
16 changes: 16 additions & 0 deletions pkg/kube/pod/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, "")
}
Expand Down
1 change: 1 addition & 0 deletions pkg/kube/unstructured/unstructured.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a0061ca

Please sign in to comment.