Skip to content

Commit 2b907a6

Browse files
committed
Notify changes in the port visibility
1 parent a4315da commit 2b907a6

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

components/ws-manager-api/go/crd/v1/workspace_types.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,22 @@ type PortSpec struct {
150150
Protocol PortProtocol `json:"protocol"`
151151
}
152152

153+
func (ps PortSpec) Equal(other PortSpec) bool {
154+
if ps.Port != other.Port {
155+
return false
156+
}
157+
158+
if ps.Visibility != other.Visibility {
159+
return false
160+
}
161+
162+
if ps.Protocol != other.Protocol {
163+
return false
164+
}
165+
166+
return true
167+
}
168+
153169
// WorkspaceStatus defines the observed state of Workspace
154170
type WorkspaceStatus struct {
155171
PodStarts int `json:"podStarts"`

components/ws-manager-mk2/controllers/subscriber_controller.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222

2323
config "github.com/gitpod-io/gitpod/ws-manager/api/config"
2424
workspacev1 "github.com/gitpod-io/gitpod/ws-manager/api/crd/v1"
25+
"github.com/google/go-cmp/cmp"
2526
)
2627

2728
func NewSubscriberReconciler(c client.Client, cfg *config.Configuration) (*SubscriberReconciler, error) {
@@ -80,10 +81,17 @@ func (r *SubscriberReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Ma
8081
}()
8182

8283
filterByStatus := predicate.Funcs{
84+
CreateFunc: func(ce event.CreateEvent) bool {
85+
return true
86+
},
8387
UpdateFunc: func(e event.UpdateEvent) bool {
8488
old := e.ObjectOld.(*workspacev1.Workspace)
8589
new := e.ObjectNew.(*workspacev1.Workspace)
8690

91+
if !cmp.Equal(old.Spec.Ports, new.Spec.Ports) {
92+
return true
93+
}
94+
8795
return !equality.Semantic.DeepDerivative(old.Status, new.Status)
8896
},
8997
}

0 commit comments

Comments
 (0)