fix addon panic bug (#3026)

Signed-off-by: wangyike <wangyike_wyk@163.com>

Fix lint

Signed-off-by: wangyike <wangyike_wyk@163.com>
This commit is contained in:
wyike
2022-01-05 13:40:51 +08:00
committed by GitHub
parent acac0554f3
commit c170cecd34
3 changed files with 9 additions and 2 deletions
+5
View File
@@ -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")
}
+2 -2
View File
@@ -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)
+2
View File
@@ -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{