pkg: add a function to generate chain names
Adds a function to generate chain names for use in iptables and ports all drivers to use that function. Also adds tests for the said function.
This commit is contained in:

committed by
Stefan Junker

parent
dc44feb5b5
commit
b87cf1ba9c
18
utils/utils_test.go
Normal file
18
utils/utils_test.go
Normal file
@ -0,0 +1,18 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
var _ = Describe("Utils", func() {
|
||||
It("should format a short name", func() {
|
||||
chain := FormatChainName("test", "1234")
|
||||
Expect(chain).To(Equal("CNI-test-d404559f602eab6f"))
|
||||
})
|
||||
|
||||
It("should truncate a long name", func() {
|
||||
chain := FormatChainName("testalongnamethatdoesnotmakesense", "1234")
|
||||
Expect(chain).To(Equal("CNI-testalongnamethat-d404559f602eab6f"))
|
||||
})
|
||||
})
|
Reference in New Issue
Block a user