feat: use package.json to show project infos
Signed-off-by: martin <martin.labat92@gmail.com>
This commit is contained in:
parent
bf3ea6ad35
commit
4022be77ae
2 changed files with 25 additions and 1 deletions
|
@ -10,5 +10,7 @@ RUN go get -d -v ./src/ && \
|
||||||
FROM alpine:3.17
|
FROM alpine:3.17
|
||||||
|
|
||||||
COPY --from=builder /go/bin/immich-exporter /go/bin/immich-exporter
|
COPY --from=builder /go/bin/immich-exporter /go/bin/immich-exporter
|
||||||
|
COPY package.json /go/bin/
|
||||||
|
|
||||||
|
WORKDIR /go/bin
|
||||||
CMD ["/go/bin/immich-exporter"]
|
CMD ["/go/bin/immich-exporter"]
|
||||||
|
|
24
src/init.go
24
src/init.go
|
@ -1,9 +1,11 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"flag"
|
"flag"
|
||||||
"immich-exporter/src/immich"
|
"immich-exporter/src/immich"
|
||||||
"immich-exporter/src/models"
|
"immich-exporter/src/models"
|
||||||
|
"io/ioutil"
|
||||||
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
@ -12,11 +14,11 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func startup() {
|
func startup() {
|
||||||
|
projectinfo()
|
||||||
var envfile bool
|
var envfile bool
|
||||||
|
|
||||||
flag.BoolVar(&envfile, "e", false, "Use .env file")
|
flag.BoolVar(&envfile, "e", false, "Use .env file")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
log.Println("Loading all parameters")
|
|
||||||
if envfile {
|
if envfile {
|
||||||
useenvfile()
|
useenvfile()
|
||||||
} else {
|
} else {
|
||||||
|
@ -27,8 +29,27 @@ func startup() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func projectinfo() {
|
||||||
|
fileContent, err := os.Open("./package.json")
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
defer fileContent.Close()
|
||||||
|
|
||||||
|
byteResult, _ := ioutil.ReadAll(fileContent)
|
||||||
|
|
||||||
|
var res map[string]interface{}
|
||||||
|
json.Unmarshal([]byte(byteResult), &res)
|
||||||
|
log.Println("Author :", res["author"])
|
||||||
|
log.Println(res["name"], "version", res["version"])
|
||||||
|
}
|
||||||
|
|
||||||
func useenvfile() {
|
func useenvfile() {
|
||||||
myEnv, err := godotenv.Read()
|
myEnv, err := godotenv.Read()
|
||||||
|
|
||||||
username := myEnv["IMMICH_USERNAME"]
|
username := myEnv["IMMICH_USERNAME"]
|
||||||
password := myEnv["IMMICH_PASSWORD"]
|
password := myEnv["IMMICH_PASSWORD"]
|
||||||
immich_url := myEnv["IMMICH_BASE_URL"]
|
immich_url := myEnv["IMMICH_BASE_URL"]
|
||||||
|
@ -50,6 +71,7 @@ func useenvfile() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func initenv() {
|
func initenv() {
|
||||||
|
|
||||||
username := os.Getenv("IMMICH_USERNAME")
|
username := os.Getenv("IMMICH_USERNAME")
|
||||||
password := os.Getenv("IMMICH_PASSWORD")
|
password := os.Getenv("IMMICH_PASSWORD")
|
||||||
immich_url := os.Getenv("IMMICH_BASE_URL")
|
immich_url := os.Getenv("IMMICH_BASE_URL")
|
||||||
|
|
Loading…
Reference in a new issue