docker-register-manager/internal/app/app.go

34 lines
751 B
Go
Raw Normal View History

2024-09-30 19:31:22 +03:00
package app
import (
"fmt"
"os"
)
type App struct {
RegistryName string
RegistryURL string
RegistryUsername string
RegistryPassword string
}
func NewApp() (*App, error) {
registryName := os.Getenv("REGISTRY_NAME")
if registryName == "" {
return nil, fmt.Errorf("REGISTRY_NAME not found in .env")
}
registryUsername := os.Getenv("REGISTRY_USERNAME")
registryPassword := os.Getenv("REGISTRY_PASSWORD")
if registryUsername == "" || registryPassword == "" {
return nil, fmt.Errorf("REGISTRY_USERNAME or REGISTRY_PASSWORD not found in .env")
}
return &App{
RegistryName: registryName,
RegistryURL: "https://" + registryName,
RegistryUsername: registryUsername,
RegistryPassword: registryPassword,
}, nil
}