Skip to content

Commit

Permalink
Merge pull request #518 from dusdjhyeon/dusdjhyeon/utils/catalog-package
Browse files Browse the repository at this point in the history
Set DisplayName and Name in artifacthub-pkg
  • Loading branch information
Mohd Uzair authored Jun 27, 2024
2 parents c451ae2 + e147e0d commit ae755c6
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions utils/catalog/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ package catalog

import (
"fmt"

"regexp"
"strings"
"github.com/layer5io/meshkit/models/catalog/v1alpha1"
)

func BuildArtifactHubPkg(name, downloadURL, user, version, createdAt string, catalogData *v1alpha1.CatalogData) *ArtifactHubMetadata {
artifacthubPkg := &ArtifactHubMetadata{
Name: name,
Name: toKebabCase(name),
DisplayName: name,
Description: catalogData.PatternInfo,
Provider: Provider{
Name: user,
Expand Down Expand Up @@ -53,3 +55,12 @@ func BuildArtifactHubPkg(name, downloadURL, user, version, createdAt string, cat

return artifacthubPkg
}

func toKebabCase(s string) string {
s = strings.ToLower(s)
re := regexp.MustCompile(`\s+`)
s = re.ReplaceAllString(s, " ")
s = strings.ReplaceAll(s, " ", "-")

return s
}

0 comments on commit ae755c6

Please sign in to comment.