func GetJobs()

in images/controller/pkg/util.go [289:308]


func GetJobs(namespace, selector string) ([]GetJobSpec, error) {
	resp := make([]GetJobSpec, 0)

	type getJobsList struct {
		Items []GetJobSpec `json:"items"`
	}

	cmd := exec.Command("sh", "-c", fmt.Sprintf("kubectl get jobs -n %s -l %s -o json 1>&2", namespace, selector))
	stdoutStderr, err := cmd.CombinedOutput()
	if err != nil {
		return resp, fmt.Errorf("failed to get jobs: %s, %v", string(stdoutStderr), err)
	}

	var jsonResp getJobsList
	if err := json.Unmarshal(stdoutStderr, &jsonResp); err != nil {
		return resp, fmt.Errorf("failed to parse jobs spec: %v", err)
	}

	return jsonResp.Items, nil
}