Skip to content

Commit

Permalink
fix: match container
Browse files Browse the repository at this point in the history
  • Loading branch information
zwk1091 committed Jan 4, 2024
1 parent 3fb97a6 commit c78ed82
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions chaosmeta-inject-operator/pkg/selector/selector.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ import (
)

const (
HostIPKey = ".status.hostIP"
PhaseKey = ".status.phase"
HostIPKey = ".status.hostIP"
PhaseKey = ".status.phase"
containerRegFmt = "^(%s)$"
)

var (
Expand Down Expand Up @@ -227,7 +228,6 @@ func GetTargetContainers(containerReg string, status []corev1.ContainerStatus) (
return
}
containerReg = strings.ReplaceAll(containerReg, ",", "|")
reg := regexp.MustCompile(containerReg)
containers = []model.ContainerInfo{}
var targetContainerInfo corev1.ContainerStatus
// no container setting equals to firstcontainer setting
Expand All @@ -239,6 +239,7 @@ func GetTargetContainers(containerReg string, status []corev1.ContainerStatus) (
}
containers = append(containers, *info)
} else {
reg := regexp.MustCompile(fmt.Sprintf(containerRegFmt, containerReg))
for _, containerStatus := range status {
if reg.MatchString(containerStatus.Name) {
info, err := getContainerInfo(containerStatus)
Expand Down

0 comments on commit c78ed82

Please sign in to comment.