Skip to content

Commit

Permalink
fix(): schema file path fix and env introduced
Browse files Browse the repository at this point in the history
* fix(): event schema file moved to pkg

Signed-off-by: Puran Adhikari <[email protected]>

* fix(): schema file fix with env

Signed-off-by: Puran Adhikari <[email protected]>

* fix(): file path change

Signed-off-by: Puran Adhikari <[email protected]>

---------

Signed-off-by: Puran Adhikari <[email protected]>
  • Loading branch information
PuranAdhikari authored Feb 27, 2023
1 parent f30db02 commit e8da0f8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
File renamed without changes.
File renamed without changes.
14 changes: 12 additions & 2 deletions pkg/schema/event_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package schema
import (
"k8s.io/apimachinery/pkg/util/yaml"
"os"
"path"
)

type EventType string
Expand All @@ -26,11 +27,20 @@ type EventSchema struct {
}

func GetEvent(name string) (*EventSchema, error) {
controllerEvents, err := parseEvent("../schema/config/controller.yaml")
file1 := "controller.yaml"
file2 := "worker.yaml"
controllerFilePath := path.Join("../../config/events", file1)
workerFilePath := path.Join("../../config/events", file2)
dir := os.Getenv("EVENT_SCHEMA_PATH")
if dir != "" {
controllerFilePath = path.Join(dir, file1)
workerFilePath = path.Join(dir, file2)
}
controllerEvents, err := parseEvent(controllerFilePath)
if err != nil {
return nil, err
}
workerEvents, err := parseEvent("../schema/config/worker.yaml")
workerEvents, err := parseEvent(workerFilePath)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit e8da0f8

Please sign in to comment.