Skip to content

Commit 3df5a8e

Browse files
authored
Modify index generator validator (#55)
* feat: modify index generator validator Signed-off-by: jingfu wang <[email protected]> * test: add unit test Signed-off-by: jingfu wang <[email protected]>
1 parent a6054b2 commit 3df5a8e

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

index/generator/library/library.go

+3
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ func validateIndexComponent(indexComponent schema.Schema, componentType schema.D
7070
if indexComponent.Git == nil {
7171
return fmt.Errorf("index component git is empty")
7272
}
73+
if len(indexComponent.Git.Remotes) > 1 {
74+
return fmt.Errorf("index component has multiple remotes")
75+
}
7376
}
7477

7578
return nil

index/generator/library/library_test.go

+14
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,20 @@ func TestValidateIndexComponent(t *testing.T) {
8686
schema.SampleDevfileType,
8787
false,
8888
},
89+
{
90+
"Case 7: test index component git has multiple remotes",
91+
schema.Schema{
92+
Name: "nodejs",
93+
Git: &schema.Git{
94+
Remotes: map[string]string{
95+
"origin": "https://github.com/redhat-developer/devfile-sample",
96+
"test": "https://github.com/redhat-developer/test",
97+
},
98+
},
99+
},
100+
schema.SampleDevfileType,
101+
true,
102+
},
89103
}
90104

91105
for _, tt := range tests {

0 commit comments

Comments
 (0)