mirror of
https://github.com/kubernetes-sigs/node-feature-discovery.git
synced 2024-12-14 11:57:51 +00:00
Drop 'nfd' prefix from the label names
No need for that anymore as annotations are used to keep track of labels managed by nfd. This also makes the feature labels more generic with no traces of the NFD project name. This makes way for "standardizing" the node feature labels in a larger architectural scope, in case that was something that would be pursued in the future.
This commit is contained in:
parent
15f8f4437b
commit
0259f0652a
2 changed files with 6 additions and 7 deletions
7
main.go
7
main.go
|
@ -46,8 +46,7 @@ const (
|
|||
)
|
||||
|
||||
var (
|
||||
version = "" // Must not be const, set using ldflags at build time
|
||||
labelPrefix = labelNs + "nfd-"
|
||||
version = "" // Must not be const, set using ldflags at build time
|
||||
)
|
||||
|
||||
// package loggers
|
||||
|
@ -443,13 +442,13 @@ func (h k8sHelpers) RemoveLabelsWithPrefix(n *api.Node, search string) {
|
|||
// RemoveLabels removes given NFD labels
|
||||
func (h k8sHelpers) RemoveLabels(n *api.Node, labelNames []string) {
|
||||
for _, l := range labelNames {
|
||||
delete(n.Labels, labelPrefix+l)
|
||||
delete(n.Labels, labelNs+l)
|
||||
}
|
||||
}
|
||||
|
||||
func (h k8sHelpers) AddLabels(n *api.Node, labels Labels) {
|
||||
for k, v := range labels {
|
||||
n.Labels[labelPrefix+k] = v
|
||||
n.Labels[labelNs+k] = v
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ func TestDiscoveryWithMockSources(t *testing.T) {
|
|||
mockAPIHelper.On("GetClient").Return(mockClient, nil)
|
||||
mockAPIHelper.On("GetNode", mockClient).Return(mockNode, nil).Once()
|
||||
mockAPIHelper.On("AddLabels", mockNode, fakeFeatureLabels).Return().Once()
|
||||
mockAPIHelper.On("RemoveLabelsWithPrefix", mockNode, labelPrefix).Return().Once()
|
||||
mockAPIHelper.On("RemoveLabelsWithPrefix", mockNode, labelNs).Return().Once()
|
||||
mockAPIHelper.On("RemoveLabelsWithPrefix", mockNode, "node.alpha.kubernetes-incubator.io/nfd").Return().Once()
|
||||
mockAPIHelper.On("RemoveLabelsWithPrefix", mockNode, "node.alpha.kubernetes-incubator.io/node-feature-discovery").Return().Once()
|
||||
mockAPIHelper.On("AddAnnotations", mockNode, fakeAnnotations).Return().Once()
|
||||
|
@ -122,7 +122,7 @@ func TestDiscoveryWithMockSources(t *testing.T) {
|
|||
expectedError := errors.New("fake error")
|
||||
mockAPIHelper.On("GetClient").Return(mockClient, nil)
|
||||
mockAPIHelper.On("GetNode", mockClient).Return(mockNode, nil).Once()
|
||||
mockAPIHelper.On("RemoveLabelsWithPrefix", mockNode, labelPrefix).Return().Once()
|
||||
mockAPIHelper.On("RemoveLabelsWithPrefix", mockNode, labelNs).Return().Once()
|
||||
mockAPIHelper.On("RemoveLabelsWithPrefix", mockNode, "node.alpha.kubernetes-incubator.io/nfd").Return().Once()
|
||||
mockAPIHelper.On("RemoveLabelsWithPrefix", mockNode, "node.alpha.kubernetes-incubator.io/node-feature-discovery").Return().Once()
|
||||
mockAPIHelper.On("AddLabels", mockNode, fakeFeatureLabels).Return().Once()
|
||||
|
@ -339,7 +339,7 @@ func TestAddLabels(t *testing.T) {
|
|||
test1 := "test1"
|
||||
labels[test1] = "true"
|
||||
helper.AddLabels(n, labels)
|
||||
So(n.Labels, ShouldContainKey, labelPrefix+test1)
|
||||
So(n.Labels, ShouldContainKey, labelNs+test1)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue