Skip to content

Commit

Permalink
add get member cluster node
Browse files Browse the repository at this point in the history
Signed-off-by: Heylosky <2547226479@qq.com>
  • Loading branch information
Heylosky committed Oct 30, 2024
1 parent 8be6169 commit e6af8c4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
1 change: 1 addition & 0 deletions cmd/api/app/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
_ "github.com/karmada-io/dashboard/cmd/api/app/routes/ingress"
_ "github.com/karmada-io/dashboard/cmd/api/app/routes/job"
_ "github.com/karmada-io/dashboard/cmd/api/app/routes/namespace"
_ "github.com/karmada-io/dashboard/cmd/api/app/routes/node"
_ "github.com/karmada-io/dashboard/cmd/api/app/routes/overview"
_ "github.com/karmada-io/dashboard/cmd/api/app/routes/propagationpolicy"
_ "github.com/karmada-io/dashboard/cmd/api/app/routes/secret"
Expand Down
26 changes: 18 additions & 8 deletions pkg/resource/node/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@ import (
)

type Node struct {
ObjectMeta types.ObjectMeta `json:"objectMeta"`
TypeMeta types.TypeMeta `json:"typeMeta"`
Ready metav1.ConditionStatus `json:"ready,omitempty"`
KubernetesVersion string `json:"kubernetesVersion,omitempty"`
NodeSummary *v1alpha1.NodeSummary `json:"nodeSummary,omitempty"`
AllocatedResources NodeAllocatedResources `json:"allocatedResources"`
ObjectMeta types.ObjectMeta `json:"objectMeta"`
TypeMeta types.TypeMeta `json:"typeMeta"`
NodeSummary *v1alpha1.NodeSummary `json:"nodeSummary,omitempty"`
Status v1.NodeStatus `json:"status"`
}

// NodeList contains a list of node.
Expand Down Expand Up @@ -57,10 +55,11 @@ func GetNodeListFromChannels(channels *common.ResourceChannels, dsQuery *datasel
return result, nil
}

func toNode(meta metav1.ObjectMeta) Node {
func toNode(meta metav1.ObjectMeta, status v1.NodeStatus) Node {
return Node{
ObjectMeta: types.NewObjectMeta(meta),
TypeMeta: types.NewTypeMeta(types.ResourceKindNode),
Status: NewStatus(status),
}
}

Expand All @@ -76,8 +75,19 @@ func toNodeList(nodes []v1.Node, nonCriticalErrors []error, dsQuery *dataselect.
result.ListMeta = types.ListMeta{TotalItems: filteredTotal}

for _, item := range nodes {
result.Items = append(result.Items, toNode(item.ObjectMeta))
result.Items = append(result.Items, toNode(item.ObjectMeta, item.Status))
}

return result
}

func NewStatus(status v1.NodeStatus) v1.NodeStatus {
return v1.NodeStatus{
Capacity: status.Capacity,
Allocatable: status.Allocatable,
Conditions: status.Conditions,
Addresses: status.Addresses,
DaemonEndpoints: status.DaemonEndpoints,
NodeInfo: status.NodeInfo,
}
}

0 comments on commit e6af8c4

Please sign in to comment.