func ListPods()

in images/controller/pkg/util.go [310:326]


func ListPods(namespace, selector string) ([]string, error) {
	resp := make([]string, 0)
	cmd := exec.Command("sh", "-c", fmt.Sprintf("kubectl get pod -n %s -l \"%s\" -o name --sort-by=.metadata.creationTimestamp 1>&2", namespace, selector))
	stdoutStderr, err := cmd.CombinedOutput()
	if err != nil {
		return resp, fmt.Errorf("failed to get pods: %s, %v", string(stdoutStderr), err)
	}

	scanner := bufio.NewScanner(bytes.NewReader(stdoutStderr))
	for scanner.Scan() {
		line := scanner.Text()
		podName := strings.Split(line, "/")[1]
		resp = append(resp, podName)
	}

	return resp, nil
}