Merge pull request #45 from Bnyro/imageProxyUrl

include image proxy url and whether registration is disabled
This commit is contained in:
Bnyro 2023-08-14 10:36:22 +02:00 committed by GitHub
commit bacc784f59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 27 additions and 21 deletions

48
main.go
View File

@ -28,20 +28,24 @@ var monitored_instances = []Instance{}
var number_re = regexp.MustCompile(`(?m)(\d+)`) var number_re = regexp.MustCompile(`(?m)(\d+)`)
type Instance struct { type Instance struct {
Name string `json:"name"` Name string `json:"name"`
ApiUrl string `json:"api_url"` ApiUrl string `json:"api_url"`
Locations string `json:"locations"` Locations string `json:"locations"`
Version string `json:"version"` Version string `json:"version"`
UpToDate bool `json:"up_to_date"` UpToDate bool `json:"up_to_date"`
Cdn bool `json:"cdn"` Cdn bool `json:"cdn"`
Registered int `json:"registered"` Registered int `json:"registered"`
LastChecked int64 `json:"last_checked"` LastChecked int64 `json:"last_checked"`
Cache bool `json:"cache"` Cache bool `json:"cache"`
S3Enabled bool `json:"s3_enabled"` S3Enabled bool `json:"s3_enabled"`
ImageProxyUrl string `json:"image_proxy_url"`
RegistrationDisabled bool `json:"registration_disabled"`
} }
type FrontendConfig struct { type FrontendConfig struct {
S3Enabled bool `json:"s3Enabled"` S3Enabled bool `json:"s3Enabled"`
ImageProxyUrl string `json:"imageProxy"`
RegistrationDisabled bool `json:"registrationDisabled"`
} }
var client = http.Client{ var client = http.Client{
@ -182,16 +186,18 @@ func getInstanceDetails(split []string, latest string) (Instance, error) {
} }
return Instance{ return Instance{
Name: strings.TrimSpace(split[0]), Name: strings.TrimSpace(split[0]),
ApiUrl: ApiUrl, ApiUrl: ApiUrl,
Locations: strings.TrimSpace(split[2]), Locations: strings.TrimSpace(split[2]),
Cdn: strings.TrimSpace(split[3]) == "Yes", Cdn: strings.TrimSpace(split[3]) == "Yes",
Registered: int(registered), Registered: int(registered),
LastChecked: lastChecked, LastChecked: lastChecked,
Version: version, Version: version,
UpToDate: strings.Contains(latest, hash), UpToDate: strings.Contains(latest, hash),
Cache: cacheWorking, Cache: cacheWorking,
S3Enabled: config.S3Enabled, S3Enabled: config.S3Enabled,
ImageProxyUrl: config.ImageProxyUrl,
RegistrationDisabled: config.RegistrationDisabled,
}, nil }, nil
} }