Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
Signed-off-by: Anatolii Bazko <abazko@redhat.com>
  • Loading branch information
tolusha committed Oct 30, 2024
1 parent 979402e commit 2961586
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
4 changes: 2 additions & 2 deletions controllers/usernamespace/workspaces_config_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ func buildKey(gvk schema.GroupVersionKind, name string, namespace string) string

func getGkvItem(key string) string {
splits := strings.Split(key, ".")
return strings.ReplaceAll(splits[0], "#", ".")
return strings.ReplaceAll(splits[0], "-", ".")
}

func getNameItem(key string) string {
Expand All @@ -739,7 +739,7 @@ func gvk2Item(gvk schema.GroupVersionKind) string {
if gvk.Group == "" {
return fmt.Sprintf("%s_%s", gvk.Version, gvk.Kind)
}
return fmt.Sprintf("%s_%s_%s", strings.ReplaceAll(gvk.Group, ".", "#"), gvk.Version, gvk.Kind)
return fmt.Sprintf("%s_%s_%s", strings.ReplaceAll(gvk.Group, ".", "-"), gvk.Version, gvk.Kind)
}

func item2gkv(item string) schema.GroupVersionKind {
Expand Down
31 changes: 31 additions & 0 deletions controllers/usernamespace/workspaces_config_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,22 @@ func TestBuildKey(t *testing.T) {
namespace: "eclipse-che",
gkv: corev1.SchemeGroupVersion.WithKind("ConfigMap"),
},
{
name: "test_test",
namespace: "eclipse-che",
gkv: corev1.SchemeGroupVersion.WithKind("ConfigMap"),
},
{
name: "test-test",
namespace: "eclipse-che",
gkv: corev1.SchemeGroupVersion.WithKind("ConfigMap"),
},
{
name: "test-test_test.test-test_test.test",
namespace: "eclipse-che",
gkv: corev1.SchemeGroupVersion.WithKind("ConfigMap"),
},

{
name: "test",
namespace: "eclipse-che",
Expand All @@ -190,6 +206,21 @@ func TestBuildKey(t *testing.T) {
namespace: "eclipse-che",
gkv: rbacv1.SchemeGroupVersion.WithKind("ClusterRole"),
},
{
name: "test_test",
namespace: "eclipse-che",
gkv: rbacv1.SchemeGroupVersion.WithKind("ClusterRole"),
},
{
name: "test-test",
namespace: "eclipse-che",
gkv: rbacv1.SchemeGroupVersion.WithKind("ClusterRole"),
},
{
name: "test-test_test.test-test_test.test",
namespace: "eclipse-che",
gkv: rbacv1.SchemeGroupVersion.WithKind("ClusterRole"),
},
}

for i, testCase := range testCases {
Expand Down

0 comments on commit 2961586

Please sign in to comment.