From 8d2f7cb5b3b89584f23411a30b5649c1e1fa0a7b Mon Sep 17 00:00:00 2001 From: Lee Brown Date: Fri, 9 Aug 2019 09:54:56 -0800 Subject: [PATCH] Fix deploy script for domains that start with a number --- tools/devops/cmd/cicd/service_deploy.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tools/devops/cmd/cicd/service_deploy.go b/tools/devops/cmd/cicd/service_deploy.go index 3ca9fc6..38dd2e5 100644 --- a/tools/devops/cmd/cicd/service_deploy.go +++ b/tools/devops/cmd/cicd/service_deploy.go @@ -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) }