Skip to content

Commit

Permalink
Merge pull request #254 from seungsoo-lee/dev
Browse files Browse the repository at this point in the history
Updated endpoints
  • Loading branch information
seungsoo-lee committed Aug 4, 2021
2 parents 4a8dc6c + efe23fb commit bbebb45
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
22 changes: 22 additions & 0 deletions src/cluster/clusterMgmtHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,28 @@ func GetEndpointsFromCluster(cluster types.Cluster) []types.Endpoint {
if err := json.Unmarshal(b, &epCluster); err != nil {
log.Error().Msg(err.Error())
}

ep := types.Endpoint{
EndpointName: epCluster.EndpointName,
Namespace: epCluster.Namespace,
Labels: []string{},
Endpoints: []types.Mapping{},
}

for _, l := range epCluster.Labels {
ep.Labels = append(ep.Labels, l["name"]+"="+l["value"])
}

for _, m := range epCluster.Mappings {
mapping := types.Mapping{
Protocol: m["Protocol"].(string),
Port: m["port"].(int),
IP: m["ip"].(string),
}
ep.Endpoints = append(ep.Endpoints, mapping)
}

results = append(results, ep)
}

return results
Expand Down
10 changes: 5 additions & 5 deletions src/types/clusterData.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ type ServiceCluster struct {

// EndpointCluster Structure
type EndpointCluster struct {
Namespace string `json:"namespace,omitempty" bson:"namespace,omitempty"`
EndpointName string `json:"endpoint_name,omitempty" bson:"endpoint_name,omitempty"`
IP string `json:"ip,omitempty" bson:"ip,omitempty"`
Labels []map[string]string `json:"labels,omitempty" bson:"labels,omitempty"`
Mappings []map[string]string `json:"mappings" bson:"mappings"`
Namespace string `json:"namespace,omitempty" bson:"namespace,omitempty"`
EndpointName string `json:"endpoint_name,omitempty" bson:"endpoint_name,omitempty"`
IP string `json:"ip,omitempty" bson:"ip,omitempty"`
Labels []map[string]string `json:"labels,omitempty" bson:"labels,omitempty"`
Mappings []map[string]interface{} `json:"mappings" bson:"mappings"`
}

// PodCluster Structure
Expand Down

0 comments on commit bbebb45

Please sign in to comment.