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

Escape multiple entries of the same port return by the parser #99

Merged
merged 1 commit into from
Oct 5, 2019
Merged
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
16 changes: 15 additions & 1 deletion pkg/controller/siddhiprocess/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,17 @@ func (p *Parser) Parse() (applications []deploymanager.Application, err error) {
if err != nil {
return applications, err
}
portList := []int{}
for _, deploymentConf := range appConfig.DeploymentConfigs {
if !deploymentConf.IsPulling {
if !deploymentConf.IsPulling && !ContainsInt(portList, deploymentConf.Port) {
serviceEnabled = true
port := corev1.ContainerPort{
Name: "p" + strconv.Itoa(deploymentConf.Port),
ContainerPort: int32(deploymentConf.Port),
Protocol: corev1.Protocol(deploymentConf.ServiceProtocol),
}
ports = append(ports, port)
portList = append(portList, deploymentConf.Port)
protocols = append(protocols, deploymentConf.ServiceProtocol)
tls = append(tls, deploymentConf.Secured)
}
Expand Down Expand Up @@ -282,3 +284,15 @@ func getAppName(app string) (appName string, err error) {
err = errors.New("Siddhi app name extraction error")
return
}

// ContainsInt function to check given int is in the given slice or not
func ContainsInt(slice []int, value int) (contain bool) {
contain = false
for _, s := range slice {
if s == value {
contain = true
return
}
}
return
}