Skip to content

Commit

Permalink
lint check
Browse files Browse the repository at this point in the history
Signed-off-by: revolyssup <ashishjaitiwari15112000@gmail.com>
  • Loading branch information
Revolyssup committed Oct 18, 2022
1 parent 0105a9e commit a1894b6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion utils/github/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ func ErrComponentGenerate(err error) error {
}

func ErrGetGHPackage(err error) error {
return errors.New(ErrGetGHPackageCode, errors.Alert, []string{"Could not get the ArtifactHub package with the given name"}, []string{err.Error()}, []string{""}, []string{"make sure that the package exists"})
return errors.New(ErrGetGHPackageCode, errors.Alert, []string{"Could not get the Github package with the given name"}, []string{err.Error()}, []string{""}, []string{"make sure that the package exists"})
}
4 changes: 1 addition & 3 deletions utils/github/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
)

// This package is used when helm chart is fetched directly from github releases
// the format https://github.com/<Owner>/<Repository>/releases/download/<Github-tag>/<Name-Version.tgz>
// the format https://github.com/<Owner>/<Repository>/releases/download/Version/<Version/Filename.tgz>

type GithubReleasePackage struct {
Owner string
Expand Down Expand Up @@ -57,12 +57,10 @@ func (pkg *GithubReleasePackage) GetPackage() (models.Package, error) {
return nil, fmt.Errorf("no versions found for given github package")
}
pkg.Version = versions[len(versions)-1]
fmt.Println("this: ", versions)
}
if pkg.FileName == "" {
pkg.FileName = fmt.Sprintf("%s.tgz", pkg.Version)
}
pkg.URL = fmt.Sprintf("https://github.com/%s/%s/releases/download/%s/%s", pkg.Owner, pkg.Repository, pkg.Version, pkg.FileName)
fmt.Println("url is", pkg.URL)
return pkg, nil
}
16 changes: 12 additions & 4 deletions utils/github/package_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ package github
import (
"encoding/json"
"fmt"
"io/ioutil"
"io"
"os"
"testing"
)

Expand Down Expand Up @@ -34,9 +35,16 @@ func TestGetPackage(t *testing.T) {

if len(comp) != 0 {
gotData, _ := json.Marshal(comp)
expectedData, _ := ioutil.ReadFile(tt.filepath)
if string(gotData) != string(expectedData) {
t.Errorf(fmt.Sprintf("expected %s, \ngot %s", string(expectedData), string(gotData)))
file, err := os.Open(tt.filepath)
if err != nil {
t.Error(err)
}
buf, err := io.ReadAll(file)
if err != nil {
t.Error(err)
}
if string(gotData) != string(buf) {
t.Errorf(fmt.Sprintf("expected %s, \ngot %s", string(buf), string(gotData)))
}
}
}
Expand Down

0 comments on commit a1894b6

Please sign in to comment.