Skip to content

Commit

Permalink
Merge pull request meshery#555 from ctcarrier/ctcarrier/bug/fix-artif…
Browse files Browse the repository at this point in the history
…acthub-created-format

Add default values for required fields in artifacthub-pkg
  • Loading branch information
hamza-mohd authored Aug 21, 2024
2 parents 305c646 + 6bdfb1d commit 9c6bfaf
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions utils/catalog/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ func BuildArtifactHubPkg(name, downloadURL, user, version, createdAt string, cat
artifacthubPkg := &ArtifactHubMetadata{
Name: toKebabCase(name),
DisplayName: name,
Description: catalogData.PatternInfo,
Description: valueOrElse(catalogData.PatternInfo, "A Meshery Design"),
Provider: Provider{
Name: user,
},
Expand All @@ -26,7 +26,7 @@ func BuildArtifactHubPkg(name, downloadURL, user, version, createdAt string, cat
},
},
HomeURL: "https://docs.meshery.io/concepts/logical/designs",
Version: version,
Version: valueOrElse(version, "0.0.1"),
CreatedAt: createdAt,
License: "Apache-2.0",
LogoURL: "https://raw.githubusercontent.com/meshery/meshery.io/0b8585231c6e2b3251d38f749259360491c9ee6b/assets/images/brand/meshery-logo.svg",
Expand Down Expand Up @@ -56,6 +56,14 @@ func BuildArtifactHubPkg(name, downloadURL, user, version, createdAt string, cat
return artifacthubPkg
}

func valueOrElse(s string, fallback string) string {
if len(s) == 0 {
return fallback
} else {
return s
}
}

func toKebabCase(s string) string {
s = strings.ToLower(s)
re := regexp.MustCompile(`\s+`)
Expand Down

0 comments on commit 9c6bfaf

Please sign in to comment.