Skip to content

Commit

Permalink
Merge pull request #154 from getanteon/feat/named-ports
Browse files Browse the repository at this point in the history
Feat/named ports
  • Loading branch information
fatihbaltaci authored Jun 12, 2024
2 parents 0b50fc1 + 91e1489 commit a5eacf1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
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

0 comments on commit a5eacf1

Please sign in to comment.