getPodName get the first Pod name with the required role
()
| 144 | |
| 145 | // getPodName get the first Pod name with the required role |
| 146 | func (psql *Command) getPodName() (string, error) { |
| 147 | targetPodRole := specs.ClusterRoleLabelPrimary |
| 148 | if psql.Replica { |
| 149 | targetPodRole = specs.ClusterRoleLabelReplica |
| 150 | } |
| 151 | |
| 152 | for i := range psql.podList { |
| 153 | podRole, _ := utils.GetInstanceRole(psql.podList[i].Labels) |
| 154 | if podRole == targetPodRole { |
| 155 | return psql.podList[i].Name, nil |
| 156 | } |
| 157 | } |
| 158 | |
| 159 | return "", &ErrMissingPod{role: targetPodRole} |
| 160 | } |
| 161 | |
| 162 | // Exec invokes `kubectl exec` and transfers control to it. |
| 163 | // This function does not return on success. |
no test coverage detected