Skip to content

Commit c32cf26

Browse files
committed
Improve generate namespace function
1 parent d4635bb commit c32cf26

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

exp/addons/internal/controllers/clusterresourceset_controller_test.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ limitations under the License.
1717
package controllers
1818

1919
import (
20-
"crypto/sha1"
20+
"crypto/sha1" //nolint: gosec
2121
"fmt"
2222
"reflect"
2323
"testing"
@@ -978,9 +978,12 @@ func configMap(name, namespace string, data map[string]string) *corev1.ConfigMap
978978
}
979979
}
980980

981-
func randomNamespaceForTest(t testing.TB) string {
982-
h := sha1.New()
983-
h.Write([]byte(t.Name()))
981+
func randomNamespaceForTest(tb testing.TB) string {
982+
tb.Helper()
983+
// This is just to get a short form of the test name
984+
// sha1 is totally fine
985+
h := sha1.New() //nolint: gosec
986+
h.Write([]byte(tb.Name()))
984987
testNameHash := fmt.Sprintf("%x", h.Sum(nil))
985988
return "ns-" + testNameHash[:7] + "-" + util.RandomString(6)
986989
}

0 commit comments

Comments
 (0)