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

Implement gwctl describe namespaces #2795

Closed
Tracked by #2761
gauravkghildiyal opened this issue Feb 21, 2024 · 7 comments · Fixed by #2836
Closed
Tracked by #2761

Implement gwctl describe namespaces #2795

gauravkghildiyal opened this issue Feb 21, 2024 · 7 comments · Fixed by #2836
Assignees

Comments

@gauravkghildiyal
Copy link
Member

gauravkghildiyal commented Feb 21, 2024

We ideally want to have something like this as the output for gwctl describe namespace my-namespace

Name: my-namespace
Labels: 
- key1: value1
- key2: value2
Annotations: 
- key1: value1
- key2: value2
Status: Active
DirectlyAttachedPolicies:
  TYPE                   NAME
  ----                   ----
  TimeoutPolicy.foo.com  demo-timeout-policy-on-namespace
  RetryOnPolicy.baz.com  demo-retry-policy-1

If it makes things easy, to start with, you can ignore the Label, Annotation and Status fields and do that in a follow up PR (once you are somewhat comfortable with the codebase). FYI: Adding those fields involves adding a Namespace resource (instead of the just the name) to the Namespace node, and then populating it within the discoverNamespaces

@gauravkghildiyal
Copy link
Member Author

/area gwctl
/assign @Devaansh-Kumar

@k8s-ci-robot
Copy link
Contributor

@gauravkghildiyal: GitHub didn't allow me to assign the following users: Devaansh-Kumar.

Note that only kubernetes-sigs members with read permissions, repo collaborators and people who have commented on this issue/PR can be assigned. Additionally, issues/PRs can only have 10 assignees at the same time.
For more information please see the contributor guide

In response to this:

/area gwctl
/assign @Devaansh-Kumar

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@gauravkghildiyal
Copy link
Member Author

@Devaansh-Kumar -- Please use "/assign" to assign this to yourself. Do reach out if you get stuck somewhere

@Devaansh-Kumar
Copy link
Contributor

/assign

@Devaansh-Kumar
Copy link
Contributor

@gauravkghildiyal I have some confusions regarding how to phrase the command.

  1. Ideally we want to use the command in the following way: gwctl describe namespace my-namespace. If the user types just gwctl describe namespace should be describe all the namespaces available or just return an error asking to specify a namespace? And what should the behavior be if -n flag is used? According me having -n flag does not make sense.
  2. For just the namespace name and DirectlyAttachedPolicies, should I create a function like DiscoverResourcesForNamespace in discover.go?

@gauravkghildiyal
Copy link
Member Author

@Devaansh-Kumar Those are valid questions.

  1. Yes you are right, for gwctl describe namespace, we will describe all namespaces. I think what will help you here is that we're trying to match the behaviour of kubectl. Similar to kubectl, -n flag is redundant for namespaces.
  2. Yes you are on the right track.

@gauravkghildiyal
Copy link
Member Author

You don't need to use unstructured for namespaces -- simply use the k8sClients.Client to fetch a concrete corev1.Namespace typed resource.

In other words:

  1. Fetch all namespaces
  2. Wrap them in their respective nodes (inside addNamespace)

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

Successfully merging a pull request may close this issue.

3 participants