diff --git a/pkg/addon/addon_test.go b/pkg/addon/addon_test.go index d208eaf62..a76a77cf7 100644 --- a/pkg/addon/addon_test.go +++ b/pkg/addon/addon_test.go @@ -537,3 +537,8 @@ func TestGetPatternFromItem(t *testing.T) { assert.Equal(t, res, tc.meetPattern, tc.caseName) } } + +func TestGitLabReaderNotPanic(t *testing.T) { + _, err := NewAsyncReader("https://gitlab.com/test/catalog", "", "addons", "", gitType) + assert.EqualError(t, err, "git type repository only support github for now") +} diff --git a/pkg/addon/source.go b/pkg/addon/source.go index 9c84ab0cb..e386e16ba 100644 --- a/pkg/addon/source.go +++ b/pkg/addon/source.go @@ -127,8 +127,8 @@ func NewAsyncReader(baseURL, bucket, subPath, token string, rdType ReaderType) ( return nil, errors.New("addon registry invalid") } u.Path = path.Join(u.Path, subPath) - tp, content, err := utils.Parse(u.String()) - if err != nil || tp != utils.TypeGithub { + _, content, err := utils.Parse(u.String()) + if err != nil { return nil, err } gith := createGitHelper(content, token) diff --git a/pkg/utils/parse.go b/pkg/utils/parse.go index 7cbe3061f..a89f1ce7a 100644 --- a/pkg/utils/parse.go +++ b/pkg/utils/parse.go @@ -17,6 +17,7 @@ limitations under the License. package utils import ( + "fmt" "net/url" "strings" @@ -117,6 +118,7 @@ func Parse(addr string) (string, *Content, error) { }, nil default: + return "", nil, fmt.Errorf("git type repository only support github for now") } case "oss": return TypeOss, &Content{