Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PostgresCluster names and namespaces for support #75

Merged

Conversation

tony-landreth
Copy link
Contributor

Adds all reachable postgrescluster names and their namespaces to support export.

Issue: PGO-272

Adds all reachable postgrescluster names and their
namespaces to support export.

Issue: PGO-272
@tony-landreth tony-landreth force-pushed the add-clusters-namespaces-to-export branch from 6a1cfe8 to 92536d3 Compare October 30, 2023 16:14
@@ -71,6 +71,7 @@ kubectl pgo support export daisy --monitoring-namespace another-namespace --outp
| Note: No data or k8s secrets are collected.
└────────────────────────────────────────────────────────────────
Collecting PGO CLI version...
Collecting names and namespaces for PostgresClusters...
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

internal/cmd/export.go Outdated Show resolved Hide resolved
@tony-landreth tony-landreth merged commit 5ed7bcf into CrunchyData:main Oct 30, 2023
9 checks passed
Comment on lines +502 to +515
ns, found, err := unstructured.NestedString(item.Object, "metadata", "namespace")
if !found {
return fmt.Errorf("key not found: metadata.namespace")
}
if err != nil {
return err
}
name, found, err := unstructured.NestedString(item.Object, "metadata", "name")
if !found {
return fmt.Errorf("key not found: metadata.name")
}
if err != nil {
return err
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🌱 Every PostgresCluster returned from the API will have a namespace and name. There's also no harm in proceeding if we do encounter something unexpected. I think we prefer to gather the remainder of the list rather than give up early.

Suggested change
ns, found, err := unstructured.NestedString(item.Object, "metadata", "namespace")
if !found {
return fmt.Errorf("key not found: metadata.namespace")
}
if err != nil {
return err
}
name, found, err := unstructured.NestedString(item.Object, "metadata", "name")
if !found {
return fmt.Errorf("key not found: metadata.name")
}
if err != nil {
return err
}
ns, _, _ := unstructured.NestedString(item.Object, "metadata", "namespace")
name, _, _ := unstructured.NestedString(item.Object, "metadata", "name")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants