Skip to content

Commit

Permalink
Kubedb -> KubeDB (#290)
Browse files Browse the repository at this point in the history
Signed-off-by: Rokibul Hasan <[email protected]>
  • Loading branch information
RokibulHasan7 authored Mar 11, 2024
1 parent 0efafb8 commit 0db8269
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions pkg/menu/coomplete_menu.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ limitations under the License.
package menu

import (
"fmt"
"regexp"
"sort"
"strings"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/discovery"
Expand Down Expand Up @@ -57,6 +60,17 @@ func GenerateCompleteMenu(kc client.Client, disco discovery.ServerResourcesInter
Name: menuoutlines.MenuSectionName(group),
},
}

// Kubedb -> KubeDB
if strings.Contains(strings.ToLower(sec.Name), "kubedb") {
sec.Name = strings.Replace(sec.Name, "Kubedb", "KubeDB", -1)
sec.Name = strings.Replace(sec.Name, "kubedb", "KubeDB", -1)
}

// Kubedb op -> KubeDB Ops and Kubedb Postgre -> KubeDB Postgres
sec.Name = replaceWord(sec.Name, "Op", "Ops")
sec.Name = replaceWord(sec.Name, "Postgre", "Postgres")

if icons, ok := sectionIcons[group]; ok {
sec.Icons = icons
} else {
Expand Down Expand Up @@ -89,3 +103,12 @@ func GenerateCompleteMenu(kc client.Client, disco discovery.ServerResourcesInter
},
}, nil
}

func replaceWord(input, from, to string) string {
pattern := fmt.Sprintf("\\b%s\\b", from)
regexPattern := regexp.MustCompile(pattern)
if regexPattern.MatchString(input) {
return regexPattern.ReplaceAllString(input, to)
}
return input
}

0 comments on commit 0db8269

Please sign in to comment.