amocrm/internal/initialize/config.go

42 lines
2.0 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package initialize
import (
"github.com/caarlos0/env/v8"
"github.com/joho/godotenv"
"log"
)
type Config struct {
AppName string `env:"APP_NAME" envDefault:"amocrm"`
HTTPHost string `env:"HTTP_HOST" envDefault:"localhost"`
HTTPPort string `env:"HTTP_PORT" envDefault:"8001"`
PostgresCredentials string `env:"PG_CRED" envDefault:"host=localhost port=35432 user=squiz password=Redalert2 dbname=squiz sslmode=disable"`
KafkaBrokers string `env:"KAFKA_BROKERS" envDefault:"localhost:9092"`
KafkaTopic string `env:"KAFKA_TOPIC" envDefault:"test-topic"`
KafkaGroup string `env:"KAFKA_GROUP" envDefault:"amoCRM"`
RedisAddr string `env:"REDIS_ADDR" envDefault:"localhost:6379"`
RedisPassword string `env:"REDIS_PASS" envDefault:"admin"`
RedisDB int `env:"REDIS_DB" envDefault:"2"`
// урл в соц аус сервисе для генерации ссылки для авторизации в амо
PenaSocialAuthURL string `env:"PENA_SOCIAL_AUTH_URL" envDefault:"http://localhost:8000/amocrm/auth"`
// урл на который будет возвращен пользователь после авторизации это webhook/create get
ReturnURL string `env:"RETURN_URL" envDefault:"https://squiz.pena.digital/squiz/amocrm/oauth"`
// id интеграции
IntegrationID string `env:"INTEGRATION_ID" envDefault:"2dbd6329-9be6-41f2-aa5f-964b9e723e49"`
// секрет интеграции
IntegrationSecret string `env:"INTEGRATION_SECRET" envDefault:"tNK3LwL4ovP0OBK4jKDHJ3646PqRJDOKQYgY6P2t6DCuV8LEzDzszTDY0Fhwmzc8"`
//AmoStorageURL string `env:"AMO_STORAGE_URL" envDefault:"https://drive-b.amocrm.ru"`
RedirectURL string `env:"REDIRECT_URL" envDefault:"https://squiz.pena.digital/integrations"`
}
func LoadConfig() (*Config, error) {
if err := godotenv.Load(); err != nil {
log.Print("No .env file found")
}
var config Config
if err := env.Parse(&config); err != nil {
return nil, err
}
return &config, nil
}