Skip to content

Commit

Permalink
Use pointers for metadata because it is optional
Browse files Browse the repository at this point in the history
and metadata parameter is nil on finalize.

in response to PR feedback
  • Loading branch information
splkfinn committed Mar 31, 2020
1 parent 4e466b5 commit 3c23966
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
6 changes: 3 additions & 3 deletions pkg/apis/flagger/v1beta1/canary.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 15 additions & 3 deletions pkg/apis/flagger/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pkg/router/kubernetes_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,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"
Expand Down Expand Up @@ -218,7 +218,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)
}
Expand Down

0 comments on commit 3c23966

Please sign in to comment.