From 4ebdde7c15052a4b96847ec86b17f9ac596fc3fb Mon Sep 17 00:00:00 2001 From: MUzairS15 Date: Thu, 22 Feb 2024 13:54:12 +0530 Subject: [PATCH 1/4] add nil check Signed-off-by: MUzairS15 --- generators/github/package_manager.go | 3 +++ 1 file changed, 3 insertions(+) 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) From e2472b50d4cc6366a28967e7d291563b7c20bb76 Mon Sep 17 00:00:00 2001 From: MUzairS15 Date: Thu, 22 Feb 2024 13:57:55 +0530 Subject: [PATCH 2/4] add format name util Signed-off-by: MUzairS15 --- generators/generator.go | 2 ++ utils/utils.go | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) 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/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, " ", "")) +} From 84e0133ba1f98acda20296e244064dbfd9c078bb Mon Sep 17 00:00:00 2001 From: MUzairS15 Date: Thu, 22 Feb 2024 17:11:37 +0530 Subject: [PATCH 3/4] use meshkit error Signed-off-by: MUzairS15 --- utils/csv/csv.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) { From e38d7b3781c9ab27b3f872095c5c1ae65ec01a24 Mon Sep 17 00:00:00 2001 From: MUzairS15 Date: Thu, 22 Feb 2024 17:26:00 +0530 Subject: [PATCH 4/4] update error Signed-off-by: MUzairS15 --- generators/github/git_repo.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 }