mirror of
https://github.com/fluxcd/flagger.git
synced 2026-04-15 06:57:34 +00:00
Use pointers for metadata because it is optional
and metadata parameter is nil on finalize. in response to PR feedback
This commit is contained in:
committed by
stefanprodan
parent
b7441a7ce7
commit
2657e135b8
@@ -171,15 +171,15 @@ type CanaryService struct {
|
||||
|
||||
// Apex is metadata to add to the apex service
|
||||
// +optional
|
||||
Apex CustomMetadata `json:"apex,omitempty"`
|
||||
Apex *CustomMetadata `json:"apex,omitempty"`
|
||||
|
||||
// Primary is the metadata to add to the primary service
|
||||
// +optional
|
||||
Primary CustomMetadata `json:"primary,omitempty"`
|
||||
Primary *CustomMetadata `json:"primary,omitempty"`
|
||||
|
||||
// Canary is the metadata to add to the canary service
|
||||
// +optional
|
||||
Canary CustomMetadata `json:"canary,omitempty"`
|
||||
Canary *CustomMetadata `json:"canary,omitempty"`
|
||||
}
|
||||
|
||||
// CanaryAnalysis is used to describe how the analysis should be done
|
||||
|
||||
@@ -364,9 +364,21 @@ func (in *CanaryService) DeepCopyInto(out *CanaryService) {
|
||||
*out = make([]string, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
in.Apex.DeepCopyInto(&out.Apex)
|
||||
in.Primary.DeepCopyInto(&out.Primary)
|
||||
in.Canary.DeepCopyInto(&out.Canary)
|
||||
if in.Apex != nil {
|
||||
in, out := &in.Apex, &out.Apex
|
||||
*out = new(CustomMetadata)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
if in.Primary != nil {
|
||||
in, out := &in.Primary, &out.Primary
|
||||
*out = new(CustomMetadata)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
if in.Canary != nil {
|
||||
in, out := &in.Canary, &out.Canary
|
||||
*out = new(CustomMetadata)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ func (c *KubernetesDefaultRouter) GetRoutes(_ *flaggerv1.Canary) (primaryRoute i
|
||||
return 0, 0, nil
|
||||
}
|
||||
|
||||
func (c *KubernetesDefaultRouter) reconcileService(canary *flaggerv1.Canary, name string, podSelector string, metadata flaggerv1.CustomMetadata) error {
|
||||
func (c *KubernetesDefaultRouter) reconcileService(canary *flaggerv1.Canary, name string, podSelector string, metadata *flaggerv1.CustomMetadata) error {
|
||||
portName := canary.Spec.Service.PortName
|
||||
if portName == "" {
|
||||
portName = "http"
|
||||
@@ -113,6 +113,10 @@ func (c *KubernetesDefaultRouter) reconcileService(canary *flaggerv1.Canary, nam
|
||||
svcSpec.Ports = append(svcSpec.Ports, cp)
|
||||
}
|
||||
|
||||
if metadata == nil {
|
||||
metadata = &flaggerv1.CustomMetadata{}
|
||||
}
|
||||
|
||||
if metadata.Labels == nil {
|
||||
metadata.Labels = make(map[string]string)
|
||||
}
|
||||
@@ -219,7 +223,7 @@ func (c *KubernetesDefaultRouter) Finalize(canary *flaggerv1.Canary) error {
|
||||
return fmt.Errorf("service %s update error: %w", clone.Name, err)
|
||||
}
|
||||
} else {
|
||||
err = c.reconcileService(canary, apexName, canary.Spec.TargetRef.Name, canary.Spec.Service.Apex)
|
||||
err = c.reconcileService(canary, apexName, canary.Spec.TargetRef.Name, nil)
|
||||
if err != nil {
|
||||
return fmt.Errorf("reconcileService failed: %w", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user