From 2469e95dd8ca1be757d1fa07b0984c537d626b88 Mon Sep 17 00:00:00 2001 From: jingfu wang Date: Thu, 13 May 2021 11:55:34 -0400 Subject: [PATCH 1/2] feat: modify index generator validator Signed-off-by: jingfu wang --- index/generator/library/library.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/index/generator/library/library.go b/index/generator/library/library.go index 65780478f..944997c9f 100644 --- a/index/generator/library/library.go +++ b/index/generator/library/library.go @@ -70,6 +70,9 @@ func validateIndexComponent(indexComponent schema.Schema, componentType schema.D if indexComponent.Git == nil { return fmt.Errorf("index component git is empty") } + if len(indexComponent.Git.Remotes) > 1 { + return fmt.Errorf("index component has multiple remotes") + } } return nil From d9dad9463cc6645c6530aac192308e32f267918d Mon Sep 17 00:00:00 2001 From: jingfu wang Date: Mon, 17 May 2021 14:47:17 -0400 Subject: [PATCH 2/2] test: add unit test Signed-off-by: jingfu wang --- index/generator/library/library_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/index/generator/library/library_test.go b/index/generator/library/library_test.go index 3860fa7e6..5465840d6 100644 --- a/index/generator/library/library_test.go +++ b/index/generator/library/library_test.go @@ -86,6 +86,20 @@ func TestValidateIndexComponent(t *testing.T) { schema.SampleDevfileType, false, }, + { + "Case 7: test index component git has multiple remotes", + schema.Schema{ + Name: "nodejs", + Git: &schema.Git{ + Remotes: map[string]string{ + "origin": "https://github.com/redhat-developer/devfile-sample", + "test": "https://github.com/redhat-developer/test", + }, + }, + }, + schema.SampleDevfileType, + true, + }, } for _, tt := range tests {