Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/named ports #154

Merged
merged 2 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions aggregator/persist.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,20 @@ func (a *Aggregator) processSvc(d k8s.K8sResourceMessage) {
service := d.Object.(*corev1.Service)

ports := []struct {
Name string "json:\"name\""
Src int32 "json:\"src\""
Dest int32 "json:\"dest\""
Protocol string "json:\"protocol\""
}{}

for _, port := range service.Spec.Ports {
ports = append(ports, struct {
Name string "json:\"name\""
Src int32 "json:\"src\""
Dest int32 "json:\"dest\""
Protocol string "json:\"protocol\""
}{
Name: port.Name, // https://kubernetes.io/docs/concepts/services-networking/service/#field-spec-ports
Src: port.Port,
Dest: int32(port.TargetPort.IntValue()),
Protocol: string(port.Protocol),
Expand Down Expand Up @@ -268,6 +271,7 @@ func (a *Aggregator) processEndpoints(ep k8s.K8sResourceMessage) {
ports = append(ports, datastore.AddressPort{
Port: port.Port,
Protocol: string(port.Protocol),
Name: port.Name,
})
}

Expand Down
2 changes: 2 additions & 0 deletions datastore/dto.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type Service struct {
ClusterIP string
ClusterIPs []string
Ports []struct {
Name string `json:"name"`
Src int32 `json:"src"`
Dest int32 `json:"dest"`
Protocol string `json:"protocol"`
Expand Down Expand Up @@ -72,6 +73,7 @@ type AddressIP struct {
type AddressPort struct {
Port int32 `json:"port"` // Port number
Protocol string `json:"protocol"` // TCP or UDP
Name string `json:"name"`
}

// Subsets
Expand Down
1 change: 1 addition & 0 deletions datastore/payload.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ type SvcEvent struct {
Type string `json:"type"`
ClusterIPs []string `json:"cluster_ips"`
Ports []struct {
Name string `json:"name"`
Src int32 `json:"src"`
Dest int32 `json:"dest"`
Protocol string `json:"protocol"`
Expand Down
Loading