mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-25 10:18:59 +02:00
feat(route): add ExcludedReason field
This commit is contained in:
@@ -68,7 +68,8 @@ type (
|
|||||||
LisURL *nettypes.URL `json:"lurl,omitempty" swaggertype:"string" extensions:"x-nullable"`
|
LisURL *nettypes.URL `json:"lurl,omitempty" swaggertype:"string" extensions:"x-nullable"`
|
||||||
ProxyURL *nettypes.URL `json:"purl,omitempty" swaggertype:"string"`
|
ProxyURL *nettypes.URL `json:"purl,omitempty" swaggertype:"string"`
|
||||||
|
|
||||||
Excluded *bool `json:"excluded"`
|
Excluded bool `json:"excluded,omitempty" extensions:"x-nullable"`
|
||||||
|
ExcludedReason string `json:"excluded_reason,omitempty" extensions:"x-nullable"`
|
||||||
|
|
||||||
impl types.Route
|
impl types.Route
|
||||||
task *task.Task
|
task *task.Task
|
||||||
@@ -258,8 +259,10 @@ func (r *Route) Validate() gperr.Error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
r.impl = impl
|
r.impl = impl
|
||||||
excluded := r.ShouldExclude()
|
r.Excluded = r.ShouldExclude()
|
||||||
r.Excluded = &excluded
|
if r.Excluded {
|
||||||
|
r.ExcludedReason = r.GetExcludedReason()
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -438,8 +441,8 @@ func (r *Route) ShouldExclude() bool {
|
|||||||
if r.lastError != nil {
|
if r.lastError != nil {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if r.Excluded != nil {
|
if r.Excluded {
|
||||||
return *r.Excluded
|
return true
|
||||||
}
|
}
|
||||||
if r.Container != nil {
|
if r.Container != nil {
|
||||||
switch {
|
switch {
|
||||||
@@ -461,6 +464,33 @@ func (r *Route) ShouldExclude() bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *Route) GetExcludedReason() string {
|
||||||
|
if r.lastError != nil {
|
||||||
|
return string(gperr.Plain(r.lastError))
|
||||||
|
}
|
||||||
|
if r.ExcludedReason != "" {
|
||||||
|
return r.ExcludedReason
|
||||||
|
}
|
||||||
|
if r.Container != nil {
|
||||||
|
switch {
|
||||||
|
case r.Container.IsExcluded:
|
||||||
|
return "Manual exclusion"
|
||||||
|
case r.IsZeroPort() && !r.UseIdleWatcher():
|
||||||
|
return "No port exposed in container"
|
||||||
|
case !r.Container.IsExplicit && docker.IsBlacklisted(r.Container):
|
||||||
|
return "Blacklisted (backend service or database)"
|
||||||
|
case strings.HasPrefix(r.Container.ContainerName, "buildx_"):
|
||||||
|
return "Buildx"
|
||||||
|
}
|
||||||
|
} else if r.IsZeroPort() && r.Scheme != route.SchemeFileServer {
|
||||||
|
return "No port specified"
|
||||||
|
}
|
||||||
|
if strings.HasSuffix(r.Alias, "-old") {
|
||||||
|
return "Container renaming intermediate state"
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
func (r *Route) UseLoadBalance() bool {
|
func (r *Route) UseLoadBalance() bool {
|
||||||
return r.LoadBalance != nil && r.LoadBalance.Link != ""
|
return r.LoadBalance != nil && r.LoadBalance.Link != ""
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user