Skip to content

Commit

Permalink
fix dashboard counts
Browse files Browse the repository at this point in the history
  • Loading branch information
hookenz committed May 20, 2024
1 parent 9806a8d commit 161e554
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions api/internal/concurrent/concurrent.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@ import (

// Result contains the result and any error returned from running a client task function
type Result struct {
Result interface{} // the result of running the task function
Err error // any error that occurred while running the task function
Result any // the result of running the task function
Err error // any error that occurred while running the task function
}

// Func is a function returns a result or error
type Func func(ctx context.Context) (interface{}, error)
type Func func(ctx context.Context) (any, error)

// Run runs a list of functions returns the results
func Run(ctx context.Context, maxConcurrency int, tasks ...Func) ([]Result, error) {
Expand Down
12 changes: 6 additions & 6 deletions api/kubernetes/cli/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func (kcl *KubeClient) GetDashboard() (models.K8sDashboard, error) {
}

getNamespaceCounts := func(namespace string) concurrent.Func {
return func(ctx context.Context) (interface{}, error) {
return func(ctx context.Context) (any, error) {
data := models.K8sDashboard{}

// apps (deployments, statefulsets, daemonsets)
Expand Down Expand Up @@ -174,7 +174,7 @@ func getServicesCount(ctx context.Context, kcl *KubeClient, namespace string) (i
count = 1 // first service
remainingItemsCount := services.GetRemainingItemCount()
if remainingItemsCount != nil {
count = *remainingItemsCount // add the remaining services if any
count += *remainingItemsCount // add the remaining services if any
}
}

Expand All @@ -193,7 +193,7 @@ func getIngressesCount(ctx context.Context, kcl *KubeClient, namespace string) (
count = 1 // first ingress
remainingItemsCount := ingresses.GetRemainingItemCount()
if remainingItemsCount != nil {
count = *remainingItemsCount // add the remaining ingresses if any
count += *remainingItemsCount // add the remaining ingresses if any
}
}

Expand All @@ -212,7 +212,7 @@ func getConfigMapsCount(ctx context.Context, kcl *KubeClient, namespace string)
count = 1 // first configmap
remainingItemsCount := configMaps.GetRemainingItemCount()
if remainingItemsCount != nil {
count = *remainingItemsCount // add the remaining configmaps if any
count += *remainingItemsCount // add the remaining configmaps if any
}
}

Expand All @@ -231,7 +231,7 @@ func getSecretsCount(ctx context.Context, kcl *KubeClient, namespace string) (in
count = 1 // first secret
remainingItemsCount := secrets.GetRemainingItemCount()
if remainingItemsCount != nil {
count = *remainingItemsCount // add the remaining secrets if any
count += *remainingItemsCount // add the remaining secrets if any
}
}

Expand All @@ -250,7 +250,7 @@ func getVolumesCount(ctx context.Context, kcl *KubeClient, namespace string) (in
count = 1 // first volume
remainingItemsCount := volumes.GetRemainingItemCount()
if remainingItemsCount != nil {
count = *remainingItemsCount // add the remaining volumes if any
count += *remainingItemsCount // add the remaining volumes if any
}
}

Expand Down

0 comments on commit 161e554

Please sign in to comment.