diff --git a/.gitignore b/.gitignore index 88be964..bdb220a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ -id_rsa +data/id_rsa repos/ skipped.yaml diff --git a/Dockerfile b/Dockerfile index 522f1c4..2709115 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,9 +12,9 @@ WORKDIR /app # Copy the binary and config file from the builder stage COPY --from=builder /app/controlla /app/ -COPY config.yaml /app/ +COPY data/config.yaml /app/data/config.yaml # Install bash for potential scripting needs RUN apk add --no-cache bash -CMD ["./controlla"] \ No newline at end of file +CMD ["./controlla --config-file /app/data/config.yaml"] \ No newline at end of file diff --git a/config.yaml b/data/config.yaml similarity index 80% rename from config.yaml rename to data/config.yaml index 528350a..cbc71d8 100644 --- a/config.yaml +++ b/data/config.yaml @@ -1,8 +1,8 @@ git: repo_url: "git@example.git" - local_repo_path: ./repos/myrepo + local_repo_path: ./data/repos/myrepo branch: "main" - ssh_key_path: "id_rsa" + ssh_key_path: "./data/id_rsa" checker: watch_folder: services diff --git a/main.go b/main.go index da8f103..bf3fa61 100644 --- a/main.go +++ b/main.go @@ -13,6 +13,7 @@ import ( "crypto/sha1" "encoding/base64" "encoding/hex" + "flag" "fmt" "log" "os" @@ -153,12 +154,15 @@ func handleCallbackQuery(bot *tgbotapi.BotAPI, callback *tgbotapi.CallbackQuery, // Main entry point for the controlla application. // This service checks container images for updates and notifies via Telegram. func main() { + // Parse command-line flags + configPath := flag.String("config-file", "./data/config.yaml", "Path to config file") + flag.Parse() // Set up logging format and level logrus.SetFormatter(&logrus.TextFormatter{FullTimestamp: true}) logrus.SetLevel(logrus.InfoLevel) // Load application configuration from YAML file - appConfig, err := config.LoadConfig("config.yaml") + appConfig, err := config.LoadConfig(*configPath) if err != nil { log.Fatalf("Error loading application configuration: %v", err) }