Skip to content

Commit

Permalink
Making GetModuleReady/GetDevicePluginReadyLabels functions public (#672
Browse files Browse the repository at this point in the history
…) (#937)

since "ready" labels are public APIs of KMM, operators using KMM
may want to schedule they workloads based on the presence of those
labels.
  • Loading branch information
yevgeny-shnaidman authored Dec 20, 2023
1 parent 78a172a commit 929622c
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pkg/labels/labels.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package labels

import (
"github.com/rh-ecosystem-edge/kernel-module-management/internal/utils"
)

func GetKernelModuleReadyNodeLabel(namespace, moduleName string) string {
return utils.GetKernelModuleReadyNodeLabel(namespace, moduleName)
}

func GetDevicePluginNodeLabel(namespace, moduleName string) string {
return utils.GetDevicePluginNodeLabel(namespace, moduleName)
}
18 changes: 18 additions & 0 deletions pkg/labels/labels_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package labels

import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)

var _ = Describe("GetModuleReadyAndDevicePluginReadyLabels", func() {
It("module ready label", func() {
res := GetKernelModuleReadyNodeLabel("some-namespace", "some-module")
Expect(res).To(Equal("kmm.node.kubernetes.io/some-namespace.some-module.ready"))
})

It("device-plugin ready label", func() {
res := GetDevicePluginNodeLabel("some-namespace", "some-module")
Expect(res).To(Equal("kmm.node.kubernetes.io/some-namespace.some-module.device-plugin-ready"))
})
})
23 changes: 23 additions & 0 deletions pkg/labels/suite_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package labels

import (
"testing"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/rh-ecosystem-edge/kernel-module-management/internal/test"
"k8s.io/apimachinery/pkg/runtime"
)

var scheme *runtime.Scheme

func TestSuite(t *testing.T) {
RegisterFailHandler(Fail)

var err error

scheme, err = test.TestScheme()
Expect(err).NotTo(HaveOccurred())

RunSpecs(t, "Job Suite")
}

0 comments on commit 929622c

Please sign in to comment.