refactor: embed ServiceSpecResolver into Deployment to handle spec only there

This commit is contained in:
Pavel Sviderski committed 2025-03-24 20:10:28 +10:00
1 parent 7a9d0cf9db
commit 3910101a88
17 files changed
+191 -148

No files matched your search

+31
View File
@@ -120,6 +120,18 @@ func (s *ServiceSpec) Equals(spec ServiceSpec) bool {
return reflect.DeepEqual(*s, spec)
}
func (s *ServiceSpec) Clone() ServiceSpec {
spec := *s
if s.Ports != nil {
spec.Ports = make([]PortSpec, len(s.Ports))
copy(spec.Ports, s.Ports)
}
spec.Container = s.Container.Clone()
return spec
}
type ContainerSpec struct {
// Command overrides the default CMD of the image to be executed when running a container.
Command []string
@@ -140,6 +152,25 @@ func (s *ContainerSpec) Validate() error {
return nil
}
func (s *ContainerSpec) Clone() ContainerSpec {
spec := *s
if s.Command != nil {
spec.Command = make([]string, len(s.Command))
copy(spec.Command, s.Command)
}
if s.Entrypoint != nil {
spec.Entrypoint = make([]string, len(s.Entrypoint))
copy(spec.Entrypoint, s.Entrypoint)
}
if s.Volumes != nil {
spec.Volumes = make([]string, len(s.Volumes))
copy(spec.Volumes, s.Volumes)
}
return spec
}
type Service struct {
ID string
Name string