Skip to content

Commit 6c21b7c

Browse files
committed
fix file:// validation bug
1 parent 4993f54 commit 6c21b7c

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Fix 'file://' prefix validation bug

framework/components/dockercompose/chip_ingress_set/protos.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@ func validateRepoConfiguration(repoConfig ProtoSchemaSet) error {
4545
return errors.New("uri has to start with either 'file://' or 'https://'")
4646
}
4747

48+
if strings.HasPrefix(repoConfig.URI, "file://") {
49+
if repoConfig.Ref != "" {
50+
return errors.New("ref is not supported with local protos with 'file://' prefix")
51+
}
52+
53+
return nil
54+
}
55+
4856
trimmedURI := strings.TrimPrefix(repoConfig.URI, "https://")
4957
if !strings.HasPrefix(trimmedURI, "github.com") {
5058
return fmt.Errorf("only repositories hosted at github.com are supported, but %s was found", repoConfig.URI)
@@ -55,12 +63,8 @@ func validateRepoConfiguration(repoConfig ProtoSchemaSet) error {
5563
return fmt.Errorf("URI should have following format: 'https://github.com/<OWNER>/<REPOSITORY>', but %s was found", repoConfig.URI)
5664
}
5765

58-
if repoConfig.Ref == "" && strings.HasPrefix(repoConfig.URI, "https://") {
59-
return errors.New("ref is required, when fetching protos from Github")
60-
}
61-
62-
if repoConfig.Ref != "" && strings.HasPrefix(repoConfig.URI, "file://") {
63-
return errors.New("ref is not supported with local protos")
66+
if repoConfig.Ref == "" {
67+
return errors.New("ref is required, when fetching protos from Github repository")
6468
}
6569

6670
return nil

0 commit comments

Comments
 (0)