34 lines
751 B
Go
34 lines
751 B
Go
|
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
|
||
|
}
|