mirror of
https://github.com/netbirdio/netbird.git
synced 2026-04-18 08:16:39 +00:00
[management] add terminated field to service (#5700)
This commit is contained in:
@@ -519,9 +519,13 @@ func (m *Manager) executeServiceUpdate(ctx context.Context, transaction store.St
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := validateProtocolChange(existingService.Mode, service.Mode); err != nil {
|
if existingService.Terminated {
|
||||||
return err
|
return status.Errorf(status.PermissionDenied, "service is terminated and cannot be updated")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := validateProtocolChange(existingService.Mode, service.Mode); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
updateInfo.oldCluster = existingService.ProxyCluster
|
updateInfo.oldCluster = existingService.ProxyCluster
|
||||||
updateInfo.domainChanged = existingService.Domain != service.Domain
|
updateInfo.domainChanged = existingService.Domain != service.Domain
|
||||||
|
|||||||
@@ -184,6 +184,7 @@ type Service struct {
|
|||||||
ProxyCluster string `gorm:"index"`
|
ProxyCluster string `gorm:"index"`
|
||||||
Targets []*Target `gorm:"foreignKey:ServiceID;constraint:OnDelete:CASCADE"`
|
Targets []*Target `gorm:"foreignKey:ServiceID;constraint:OnDelete:CASCADE"`
|
||||||
Enabled bool
|
Enabled bool
|
||||||
|
Terminated bool
|
||||||
PassHostHeader bool
|
PassHostHeader bool
|
||||||
RewriteRedirects bool
|
RewriteRedirects bool
|
||||||
Auth AuthConfig `gorm:"serializer:json"`
|
Auth AuthConfig `gorm:"serializer:json"`
|
||||||
@@ -256,7 +257,7 @@ func (s *Service) ToAPIResponse() *api.Service {
|
|||||||
Protocol: api.ServiceTargetProtocol(target.Protocol),
|
Protocol: api.ServiceTargetProtocol(target.Protocol),
|
||||||
TargetId: target.TargetId,
|
TargetId: target.TargetId,
|
||||||
TargetType: api.ServiceTargetTargetType(target.TargetType),
|
TargetType: api.ServiceTargetTargetType(target.TargetType),
|
||||||
Enabled: target.Enabled,
|
Enabled: target.Enabled && !s.Terminated,
|
||||||
}
|
}
|
||||||
opts := targetOptionsToAPI(target.Options)
|
opts := targetOptionsToAPI(target.Options)
|
||||||
if opts == nil {
|
if opts == nil {
|
||||||
@@ -286,7 +287,8 @@ func (s *Service) ToAPIResponse() *api.Service {
|
|||||||
Name: s.Name,
|
Name: s.Name,
|
||||||
Domain: s.Domain,
|
Domain: s.Domain,
|
||||||
Targets: apiTargets,
|
Targets: apiTargets,
|
||||||
Enabled: s.Enabled,
|
Enabled: s.Enabled && !s.Terminated,
|
||||||
|
Terminated: &s.Terminated,
|
||||||
PassHostHeader: &s.PassHostHeader,
|
PassHostHeader: &s.PassHostHeader,
|
||||||
RewriteRedirects: &s.RewriteRedirects,
|
RewriteRedirects: &s.RewriteRedirects,
|
||||||
Auth: authConfig,
|
Auth: authConfig,
|
||||||
@@ -1125,6 +1127,7 @@ func (s *Service) Copy() *Service {
|
|||||||
ProxyCluster: s.ProxyCluster,
|
ProxyCluster: s.ProxyCluster,
|
||||||
Targets: targets,
|
Targets: targets,
|
||||||
Enabled: s.Enabled,
|
Enabled: s.Enabled,
|
||||||
|
Terminated: s.Terminated,
|
||||||
PassHostHeader: s.PassHostHeader,
|
PassHostHeader: s.PassHostHeader,
|
||||||
RewriteRedirects: s.RewriteRedirects,
|
RewriteRedirects: s.RewriteRedirects,
|
||||||
Auth: authCopy,
|
Auth: authCopy,
|
||||||
|
|||||||
@@ -2999,6 +2999,11 @@ components:
|
|||||||
type: boolean
|
type: boolean
|
||||||
description: Whether the service is enabled
|
description: Whether the service is enabled
|
||||||
example: true
|
example: true
|
||||||
|
terminated:
|
||||||
|
type: boolean
|
||||||
|
description: Whether the service has been terminated. Terminated services cannot be updated. Services that violate the Terms of Service will be terminated.
|
||||||
|
readOnly: true
|
||||||
|
example: false
|
||||||
pass_host_header:
|
pass_host_header:
|
||||||
type: boolean
|
type: boolean
|
||||||
description: When true, the original client Host header is passed through to the backend instead of being rewritten to the backend's address
|
description: When true, the original client Host header is passed through to the backend instead of being rewritten to the backend's address
|
||||||
|
|||||||
@@ -3718,6 +3718,9 @@ type Service struct {
|
|||||||
|
|
||||||
// Targets List of target backends for this service
|
// Targets List of target backends for this service
|
||||||
Targets []ServiceTarget `json:"targets"`
|
Targets []ServiceTarget `json:"targets"`
|
||||||
|
|
||||||
|
// Terminated Whether the service has been terminated. Terminated services cannot be updated. Services that violate the Terms of Service will be terminated.
|
||||||
|
Terminated *bool `json:"terminated,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ServiceMode Service mode. "http" for L7 reverse proxy, "tcp"/"udp"/"tls" for L4 passthrough.
|
// ServiceMode Service mode. "http" for L7 reverse proxy, "tcp"/"udp"/"tls" for L4 passthrough.
|
||||||
|
|||||||
Reference in New Issue
Block a user