diff --git a/generators/generator.go b/generators/generator.go index 18cca67a..959239b3 100644 --- a/generators/generator.go +++ b/generators/generator.go @@ -6,6 +6,7 @@ import ( "github.com/layer5io/meshkit/generators/artifacthub" "github.com/layer5io/meshkit/generators/github" "github.com/layer5io/meshkit/models" + "github.com/layer5io/meshkit/utils" ) const ( @@ -14,6 +15,7 @@ const ( ) func NewGenerator(registrant, url, packageName string) (models.PackageManager, error) { + registrant = utils.ReplaceSpacesAndConvertToLowercase(registrant) switch registrant { case artifactHub: return artifacthub.ArtifactHubPackageManager{ diff --git a/generators/github/git_repo.go b/generators/github/git_repo.go index 0d67a7d7..6b6bd6e0 100644 --- a/generators/github/git_repo.go +++ b/generators/github/git_repo.go @@ -85,7 +85,7 @@ func (gr GitRepo) extractRepoDetailsFromSourceURL() (owner, repo, branch, root s root = parts[3] } else { - err = ErrInvalidGitHubSourceURL(fmt.Errorf("specify owner, repo, branch and filepath in the url according to the specified source url format")) + err = ErrInvalidGitHubSourceURL(fmt.Errorf("Source URL $s is invalid, specify owner, repo, branch and filepath in the url according to the specified source url format", gr.URL.String())) } return } diff --git a/generators/github/package_manager.go b/generators/github/package_manager.go index 9ddae636..98d3d7b9 100644 --- a/generators/github/package_manager.go +++ b/generators/github/package_manager.go @@ -21,6 +21,9 @@ func (ghpm GitHubPackageManager) GetPackage() (models.Package, error) { protocol := url.Scheme downloader := NewDownloaderForScheme(protocol, url, ghpm.PackageName) + if downloader == nil { + return nil, ErrGenerateGitHubPackage(err, ghpm.PackageName) + } ghPackage, err := downloader.GetContent() if err != nil { return nil, ErrGenerateGitHubPackage(err, ghpm.PackageName) diff --git a/utils/csv/csv.go b/utils/csv/csv.go index 4230a605..e663045a 100644 --- a/utils/csv/csv.go +++ b/utils/csv/csv.go @@ -72,7 +72,7 @@ func (c *CSV[E]) Parse(ch chan E, errorChan chan error) error { } if err != nil { - return err + return utils.ErrReadFile(err, c.filePath) } if c.predicateFunc != nil && c.predicateFunc(columnNames, values) { diff --git a/utils/utils.go b/utils/utils.go index d2f48cd2..db81989f 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -365,4 +365,8 @@ func CreateDirectory(path string) error{ return err } return nil -} \ No newline at end of file +} + +func ReplaceSpacesAndConvertToLowercase(s string) string { + return strings.ToLower(strings.ReplaceAll(s, " ", "")) +}