Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions frontend/src/components/node/storyHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
* limitations under the License.
*/

import { KubeMetrics } from '../../lib/k8s/cluster';
import { KubeNode, NODE_POOL_LABEL_KEYS } from '../../lib/k8s/node';
import type { KubeMetrics } from '../../lib/k8s/cluster';
import type { KubeNode } from '../../lib/k8s/node';
import { NODE_POOL_LABEL_KEYS } from '../../lib/k8s/nodeConstants';

const creationTimestamp = new Date('2022-01-01').toISOString();

Expand Down
17 changes: 5 additions & 12 deletions frontend/src/lib/k8s/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { KubeNodeSummaryStats, nodeSummaryStats } from './api/v2/nodeSummaryApi'
import type { KubeCondition, KubeMetrics } from './cluster';
import type { KubeObjectInterface } from './KubeObject';
import { KubeObject } from './KubeObject';
import { NODE_POOL_LABEL_KEYS } from './nodeConstants';

export interface KubeNode extends KubeObjectInterface {
status: {
Expand Down Expand Up @@ -63,18 +64,6 @@ export interface KubeNode extends KubeObjectInterface {
};
}

/**
* The exact label keys checked by {@link Node.getNodePool}.
* Export this so test helpers and stories can strip them without drifting.
*/
export const NODE_POOL_LABEL_KEYS = [
'cloud.google.com/gke-nodepool',
'kubernetes.azure.com/agentpool',
'eks.amazonaws.com/nodegroup',
'kops.k8s.io/instancegroup',
'cluster.x-k8s.io/deployment-name',
] as const;

class Node extends KubeObject<KubeNode> {
static kind = 'Node';
static apiName = 'nodes';
Expand Down Expand Up @@ -170,4 +159,8 @@ class Node extends KubeObject<KubeNode> {
}
}

// Re-export for plugin compatibility. Import directly from nodeConstants.ts
// when only the label keys are needed to avoid loading the Node implementation.
export { NODE_POOL_LABEL_KEYS };

export default Node;
29 changes: 29 additions & 0 deletions frontend/src/lib/k8s/nodeConstants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright 2025 The Kubernetes Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/**
* The exact label keys checked by Node.getNodePool().
*
* Exported separately so stories, tests, and other consumers can use the
* same source of truth without importing the full Node implementation.
*/
export const NODE_POOL_LABEL_KEYS = [
'cloud.google.com/gke-nodepool',
'kubernetes.azure.com/agentpool',
'eks.amazonaws.com/nodegroup',
'kops.k8s.io/instancegroup',
'cluster.x-k8s.io/deployment-name',
] as const;
Loading