diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..cec28ac --- /dev/null +++ b/Makefile @@ -0,0 +1,19 @@ +BINARY_DIR=bin +BINARY_NAME=webhook-listener +COVERAGE_DIR=coverage + +lint: + golangci-lint run ./... +goreportcard: + goreportcard-cli -v +test: + go test ./... +test-coverage: + rm -rf ${COVERAGE_DIR} + mkdir ${COVERAGE_DIR} + go test -v -coverprofile ${COVERAGE_DIR}/cover.out ./... + go tool cover -html ${COVERAGE_DIR}/cover.out -o ${COVERAGE_DIR}/cover.html +build: + rm -rf ${BINARY_DIR} + mkdir ${BINARY_DIR} + env GOOS=linux CGO_ENABLED=0 GOARCH=amd64 go build -o ./${BINARY_DIR}/${BINARY_NAME} main.go \ No newline at end of file diff --git a/main.go b/main.go index ace9d0b..e6c6251 100644 --- a/main.go +++ b/main.go @@ -15,9 +15,13 @@ import ( ) func main() { - // Get root path - _, filename, _, _ := runtime.Caller(0) - cfg, err := config.LoadConfig(path.Join(path.Dir(filename), "configs", "app.yml")) + cfgFile := os.Getenv("CONFIG_FILE") + if cfgFile == "" { + // Get root path + _, filename, _, _ := runtime.Caller(0) + cfgFile = path.Join(path.Dir(filename), "configs", "app.yml") + } + cfg, err := config.LoadConfig(cfgFile) if err != nil { log.Fatalf("Error loading config: %v", err) }