Skip to content

Commit

Permalink
Review fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
opudrovs committed Dec 19, 2023
1 parent fa8744a commit 9ed0317
Show file tree
Hide file tree
Showing 3 changed files with 225 additions and 237 deletions.
211 changes: 0 additions & 211 deletions pkg/query/configuration/fluxobject_test.go

This file was deleted.

48 changes: 22 additions & 26 deletions pkg/query/configuration/objectkind.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,6 @@ func (o ObjectKind) Validate() error {
return nil
}

type FluxObject interface {
client.Object
}

var (
HelmReleaseObjectKind = ObjectKind{
Gvk: helmv2beta1.GroupVersion.WithKind(helmv2beta1.HelmReleaseKind),
Expand All @@ -133,8 +129,8 @@ var (
}
return hr.Spec.Suspend, nil
},
StatusFunc: defaultFluxObjectStatusFunc,
MessageFunc: defaultFluxObjectMessageFunc,
StatusFunc: defaultStatusFunc,
MessageFunc: defaultMessageFunc,
Category: CategoryAutomation,
}

Expand All @@ -158,8 +154,8 @@ var (
}
return ks.Spec.Suspend, nil
},
StatusFunc: defaultFluxObjectStatusFunc,
MessageFunc: defaultFluxObjectMessageFunc,
StatusFunc: defaultStatusFunc,
MessageFunc: defaultMessageFunc,
Category: CategoryAutomation,
}

Expand All @@ -183,8 +179,8 @@ var (
}
return hr.Spec.Suspend, nil
},
StatusFunc: defaultFluxObjectStatusFunc,
MessageFunc: defaultFluxObjectMessageFunc,
StatusFunc: defaultStatusFunc,
MessageFunc: defaultMessageFunc,
Category: CategorySource,
}

Expand All @@ -208,8 +204,8 @@ var (
}
return chart.Spec.Suspend, nil
},
StatusFunc: defaultFluxObjectStatusFunc,
MessageFunc: defaultFluxObjectMessageFunc,
StatusFunc: defaultStatusFunc,
MessageFunc: defaultMessageFunc,
Category: CategorySource,
}

Expand All @@ -233,8 +229,8 @@ var (
}
return repo.Spec.Suspend, nil
},
StatusFunc: defaultFluxObjectStatusFunc,
MessageFunc: defaultFluxObjectMessageFunc,
StatusFunc: defaultStatusFunc,
MessageFunc: defaultMessageFunc,
Category: CategorySource,
}

Expand All @@ -258,8 +254,8 @@ var (
}
return repo.Spec.Suspend, nil
},
StatusFunc: defaultFluxObjectStatusFunc,
MessageFunc: defaultFluxObjectMessageFunc,
StatusFunc: defaultStatusFunc,
MessageFunc: defaultMessageFunc,
Category: CategorySource,
}

Expand All @@ -283,8 +279,8 @@ var (
}
return b.Spec.Suspend, nil
},
StatusFunc: defaultFluxObjectStatusFunc,
MessageFunc: defaultFluxObjectMessageFunc,
StatusFunc: defaultStatusFunc,
MessageFunc: defaultMessageFunc,
Category: CategorySource,
}

Expand Down Expand Up @@ -342,7 +338,7 @@ var (
StatusFunc: func(obj client.Object, _ ObjectKind) (ObjectStatus, error) {
e, ok := obj.(*corev1.Event)
if !ok {
return nil, fmt.Errorf("object is not an Event")
return "", fmt.Errorf("object is not an Event")
}

if e.Type == "Normal" {
Expand Down Expand Up @@ -382,8 +378,8 @@ var (
}
return gs.Spec.Suspend, nil
},
StatusFunc: defaultFluxObjectStatusFunc,
MessageFunc: defaultFluxObjectMessageFunc,
StatusFunc: defaultStatusFunc,
MessageFunc: defaultMessageFunc,
Category: CategoryGitopsSet,
}

Expand Down Expand Up @@ -449,8 +445,8 @@ var (
}
return acd.Spec.Suspend, nil
},
StatusFunc: defaultFluxObjectStatusFunc,
MessageFunc: defaultFluxObjectMessageFunc,
StatusFunc: defaultStatusFunc,
MessageFunc: defaultMessageFunc,
Category: CategoryClusterDiscovery,
}
)
Expand Down Expand Up @@ -483,12 +479,12 @@ var SupportedRbacKinds = []ObjectKind{
ClusterRoleBindingObjectKind,
}

// defaultFluxObjectStatusFunc is the default status function for Flux objects.
// defaultStatusFunc is the default status function for Flux objects.
// The status of Flux objects is computed based on the values of the Conditions and Spec.Suspend fields,
// so we can standardize on that, based on the current object statuses, computed in non-Explorer UI:
// https://github.com/weaveworks/weave-gitops/blob/cc3c17632334ffa56838c4765e68ce388bde6b2f/ui/components/KubeStatusIndicator.tsx#L18-L25
// TODO: Remove the reference to non-Explorer UI logic once we move computing all object statuses to the backend.
func defaultFluxObjectStatusFunc(obj client.Object, objectKind ObjectKind) (ObjectStatus, error) {
func defaultStatusFunc(obj client.Object, objectKind ObjectKind) (ObjectStatus, error) {
if objectKind.GetConditionsFunc == nil {
return "", fmt.Errorf("missing get conditions func")
}
Expand Down Expand Up @@ -537,7 +533,7 @@ func defaultFluxObjectStatusFunc(obj client.Object, objectKind ObjectKind) (Obje
return Failed, nil
}

func defaultFluxObjectMessageFunc(obj client.Object, objectKind ObjectKind) (string, error) {
func defaultMessageFunc(obj client.Object, objectKind ObjectKind) (string, error) {
if objectKind.GetConditionsFunc == nil {
return "", fmt.Errorf("missing get conditions func")
}
Expand Down
Loading

0 comments on commit 9ed0317

Please sign in to comment.