Skip to content

Commit 65c1660

Browse files
committed
Remove 'get' from gatherNamespacedAPIResources function
This commit removes the client 'get' API call from the gatherNamespacedAPIResources function and instead uses the object returned to the 'list' object previously made. Associated CLI help output and documentation are also updated.
1 parent 4669f91 commit 65c1660

File tree

2 files changed

+25
-39
lines changed

2 files changed

+25
-39
lines changed

docs/content/reference/pgo_support_export.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,24 @@ PostgresCluster.
1313
#### RBAC Requirements
1414
Resources Verbs
1515
--------- -----
16-
configmaps [get list]
17-
cronjobs.batch [get list]
18-
deployments.apps [get list]
19-
endpoints [get list]
16+
configmaps [list]
17+
cronjobs.batch [list]
18+
deployments.apps [list]
19+
endpoints [list]
2020
events [get list]
21-
jobs.batch [get list]
21+
jobs.batch [list]
2222
namespaces [get]
2323
nodes [list]
24-
persistentvolumeclaims [get list]
25-
poddisruptionbudgets.policy [get list]
26-
pods [get list]
24+
persistentvolumeclaims [list]
25+
poddisruptionbudgets.policy [list]
26+
pods [list]
2727
pods/exec [create]
2828
pods/log [get]
2929
postgresclusters.postgres-operator.crunchydata.com [get]
30-
replicasets.apps [get list]
31-
serviceaccounts [get list]
32-
services [get list]
33-
statefulsets.apps [get list]
30+
replicasets.apps [list]
31+
serviceaccounts [list]
32+
services [list]
33+
statefulsets.apps [list]
3434

3535
Note: This RBAC needs to be cluster-scoped to retrieve information on nodes.
3636

internal/cmd/export.go

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -137,24 +137,24 @@ PostgresCluster.
137137
#### RBAC Requirements
138138
Resources Verbs
139139
--------- -----
140-
configmaps [get list]
141-
cronjobs.batch [get list]
142-
deployments.apps [get list]
143-
endpoints [get list]
140+
configmaps [list]
141+
cronjobs.batch [list]
142+
deployments.apps [list]
143+
endpoints [list]
144144
events [get list]
145-
jobs.batch [get list]
145+
jobs.batch [list]
146146
namespaces [get]
147147
nodes [list]
148-
persistentvolumeclaims [get list]
149-
poddisruptionbudgets.policy [get list]
150-
pods [get list]
148+
persistentvolumeclaims [list]
149+
poddisruptionbudgets.policy [list]
150+
pods [list]
151151
pods/exec [create]
152152
pods/log [get]
153153
postgresclusters.postgres-operator.crunchydata.com [get]
154-
replicasets.apps [get list]
155-
serviceaccounts [get list]
156-
services [get list]
157-
statefulsets.apps [get list]
154+
replicasets.apps [list]
155+
serviceaccounts [list]
156+
services [list]
157+
statefulsets.apps [list]
158158
159159
Note: This RBAC needs to be cluster-scoped to retrieve information on nodes.
160160
@@ -610,21 +610,7 @@ func gatherNamespacedAPIResources(ctx context.Context,
610610
}
611611

612612
for _, obj := range list.Items {
613-
// Get each object defined in list, marshal the object and print
614-
// to a file
615-
get, err := client.Resource(gvr).Namespace(namespace).
616-
Get(ctx, obj.GetName(), metav1.GetOptions{})
617-
if err != nil {
618-
if apierrors.IsForbidden(err) || apierrors.IsNotFound(err) {
619-
cmd.Println(err.Error())
620-
// Continue and output errors for each resource type
621-
// Allow the user to see and address all issues at once
622-
continue
623-
}
624-
return err
625-
}
626-
627-
b, err := yaml.Marshal(get)
613+
b, err := yaml.Marshal(obj)
628614
if err != nil {
629615
return err
630616
}

0 commit comments

Comments
 (0)