1
0
mirror of https://github.com/raseels-repos/golang-saas-starter-kit.git synced 2025-08-08 22:36:41 +02:00

Fix deploy script for domains that start with a number

This commit is contained in:
Lee Brown
2019-08-09 09:54:56 -08:00
parent 0cca4f31b7
commit 8d2f7cb5b3

View File

@ -861,12 +861,31 @@ func NewServiceDeployRequest(log *log.Logger, flags ServiceDeployFlags) (*servic
log.Printf("\t%s\tDefaults set.", tests.Success)
}
r, err := regexp.Compile(`^(\d+)`)
if err != nil {
return nil, errors.WithStack(err)
}
// Workaround for domains that start with a numeric value like 8north.com
// Validation fails with error: failed on the 'fqdn' tag
origServiceHostPrimary := req.ServiceHostPrimary
matches := r.FindAllString(req.ServiceHostPrimary, -1)
if len(matches) > 0 {
for _, m := range matches {
req.ServiceHostPrimary = strings.Replace(req.ServiceHostPrimary, m, "X", -1)
}
}
log.Println("\tValidate request.")
errs := validator.New().Struct(req)
if errs != nil {
return nil, errs
}
// Reset the primary domain after validation is completed.
req.ServiceHostPrimary = origServiceHostPrimary
log.Printf("\t%s\tNew request generated.", tests.Success)
}