mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-09 21:17:09 +08:00
vendor: update compose-go to v2.0.2
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
41
vendor/github.com/compose-spec/compose-go/v2/loader/validate.go
generated
vendored
41
vendor/github.com/compose-spec/compose-go/v2/loader/validate.go
generated
vendored
@ -17,7 +17,6 @@
|
||||
package loader
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
@ -71,17 +70,14 @@ func checkConsistency(project *types.Project) error {
|
||||
}
|
||||
}
|
||||
|
||||
for dependedService := range s.DependsOn {
|
||||
for dependedService, cfg := range s.DependsOn {
|
||||
if _, err := project.GetService(dependedService); err != nil {
|
||||
return fmt.Errorf("service %q depends on undefined service %s: %w", s.Name, dependedService, errdefs.ErrInvalid)
|
||||
if errors.Is(err, errdefs.ErrDisabled) && !cfg.Required {
|
||||
continue
|
||||
}
|
||||
return fmt.Errorf("service %q depends on undefined service %q: %w", s.Name, dependedService, errdefs.ErrInvalid)
|
||||
}
|
||||
}
|
||||
// Check there isn't a cycle in depends_on declarations
|
||||
if err := graph.InDependencyOrder(context.Background(), project, func(ctx context.Context, s string, config types.ServiceConfig) error {
|
||||
return nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if strings.HasPrefix(s.NetworkMode, types.ServicePrefix) {
|
||||
serviceName := s.NetworkMode[len(types.ServicePrefix):]
|
||||
@ -124,6 +120,31 @@ func checkConsistency(project *types.Project) error {
|
||||
s.Deploy.Replicas = s.Scale
|
||||
}
|
||||
|
||||
if s.CPUS != 0 && s.Deploy != nil {
|
||||
if s.Deploy.Resources.Limits != nil && s.Deploy.Resources.Limits.NanoCPUs.Value() != s.CPUS {
|
||||
return fmt.Errorf("services.%s: can't set distinct values on 'cpus' and 'deploy.resources.limits.cpus': %w",
|
||||
s.Name, errdefs.ErrInvalid)
|
||||
}
|
||||
}
|
||||
if s.MemLimit != 0 && s.Deploy != nil {
|
||||
if s.Deploy.Resources.Limits != nil && s.Deploy.Resources.Limits.MemoryBytes != s.MemLimit {
|
||||
return fmt.Errorf("services.%s: can't set distinct values on 'mem_limit' and 'deploy.resources.limits.memory': %w",
|
||||
s.Name, errdefs.ErrInvalid)
|
||||
}
|
||||
}
|
||||
if s.MemReservation != 0 && s.Deploy != nil {
|
||||
if s.Deploy.Resources.Reservations != nil && s.Deploy.Resources.Reservations.MemoryBytes != s.MemReservation {
|
||||
return fmt.Errorf("services.%s: can't set distinct values on 'mem_reservation' and 'deploy.resources.reservations.memory': %w",
|
||||
s.Name, errdefs.ErrInvalid)
|
||||
}
|
||||
}
|
||||
if s.PidsLimit != 0 && s.Deploy != nil {
|
||||
if s.Deploy.Resources.Limits != nil && s.Deploy.Resources.Limits.Pids != s.PidsLimit {
|
||||
return fmt.Errorf("services.%s: can't set distinct values on 'pids_limit' and 'deploy.resources.limits.pids': %w",
|
||||
s.Name, errdefs.ErrInvalid)
|
||||
}
|
||||
}
|
||||
|
||||
if s.ContainerName != "" {
|
||||
if existing, ok := containerNames[s.ContainerName]; ok {
|
||||
return fmt.Errorf(`"services.%s": container name "%s" is already in use by "services.%s": %w`, s.Name, s.ContainerName, existing, errdefs.ErrInvalid)
|
||||
@ -159,5 +180,5 @@ func checkConsistency(project *types.Project) error {
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
return graph.CheckCycle(project)
|
||||
}
|
||||
|
Reference in New Issue
Block a user