Skip to content

Commit

Permalink
refactor: pendingcontrollers package
Browse files Browse the repository at this point in the history
  • Loading branch information
limhawjia committed Jul 17, 2023
1 parent ab463c4 commit 9d43262
Showing 1 changed file with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ import (
"encoding/json"
"fmt"

"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"

fedcorev1a1 "github.com/kubewharf/kubeadmiral/pkg/apis/core/v1alpha1"
"github.com/kubewharf/kubeadmiral/pkg/controllers/common"
annotationutil "github.com/kubewharf/kubeadmiral/pkg/controllers/util/annotation"
)
Expand All @@ -32,7 +31,7 @@ const (
PendingControllersAnnotation = common.DefaultPrefix + "pending-controllers"
)

func GetPendingControllers(fedObject *unstructured.Unstructured) (PendingControllers, error) {
func GetPendingControllers(fedObject *fedcorev1a1.GenericFederatedObject) (PendingControllers, error) {
value, exists := fedObject.GetAnnotations()[PendingControllersAnnotation]
if !exists {
return nil, fmt.Errorf("annotation %v does not exist", PendingControllersAnnotation)
Expand Down Expand Up @@ -64,7 +63,7 @@ func NormalizeControllers(controllers PendingControllers) PendingControllers {
}

func SetPendingControllers(
fedObject *unstructured.Unstructured,
fedObject *fedcorev1a1.GenericFederatedObject,
controllers PendingControllers,
) (updated bool, err error) {
controllers = NormalizeControllers(controllers)
Expand All @@ -91,7 +90,7 @@ func getDownstreamControllers(allControllers PendingControllers, current string)
}

func UpdatePendingControllers(
fedObject *unstructured.Unstructured,
fedObject *fedcorev1a1.GenericFederatedObject,
toRemove string,
shouldSetDownstream bool,
allControllers PendingControllers,
Expand Down Expand Up @@ -125,7 +124,7 @@ func UpdatePendingControllers(
return SetPendingControllers(fedObject, newPendingControllers)
}

func ControllerDependenciesFulfilled(fedObject *unstructured.Unstructured, controllerName string) (bool, error) {
func ControllerDependenciesFulfilled(fedObject *fedcorev1a1.GenericFederatedObject, controllerName string) (bool, error) {
pendingControllers, err := GetPendingControllers(fedObject)
if err != nil {
return false, err
Expand Down

0 comments on commit 9d43262

Please sign in to comment.