MCPcopy Create free account
hub / github.com/cloudnative-pg/cloudnative-pg / getPodName

Method getPodName

internal/cmd/plugin/psql/psql.go:146–160  ·  view source on GitHub ↗

getPodName get the first Pod name with the required role

()

Source from the content-addressed store, hash-verified

144
145// getPodName get the first Pod name with the required role
146func (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.

Callers 2

getKubectlInvocationMethod · 0.95
psql_test.goFile · 0.80

Calls 1

GetInstanceRoleFunction · 0.92

Tested by

no test coverage detected