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

Colorize kubectl auth commands #88

Open
applejag opened this issue Mar 25, 2024 · 0 comments
Open

Colorize kubectl auth commands #88

applejag opened this issue Mar 25, 2024 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@applejag
Copy link
Collaborator

Expected Behavior

Correct coloring is applied to:

kubectl auth can-i                      # literal: yes / no
kubectl auth can-i --list               # table
kubectl auth can-i --list --no-headers  # table witout header

kubectl auth whoami          # table
kubectl auth whoami -o yaml  # yaml
kubectl auth whoami -o json  # json

kubectl auth reconcile -f role.yaml  # similar to "kubectl apply" coloring

Sample outputs

kubectl auth can-i

$ kubectl auth can-i get pods
yes
$ kubectl auth can-i delete pods
no
$ kubectl auth can-i --list
Resources                                       Non-Resource URLs   Resource Names   Verbs
*.*                                             []                  []               [*]
                                                [*]                 []               [*]
selfsubjectreviews.authentication.k8s.io        []                  []               [create]
selfsubjectaccessreviews.authorization.k8s.io   []                  []               [create]
selfsubjectrulesreviews.authorization.k8s.io    []                  []               [create]
                                                [/api/*]            []               [get]
                                                [/api]              []               [get]
                                                [/apis/*]           []               [get]
                                                [/apis]             []               [get]
                                                [/healthz]          []               [get]
                                                [/healthz]          []               [get]
                                                [/livez]            []               [get]
                                                [/livez]            []               [get]
                                                [/openapi/*]        []               [get]
                                                [/openapi]          []               [get]
                                                [/readyz]           []               [get]
                                                [/readyz]           []               [get]
                                                [/version/]         []               [get]
                                                [/version/]         []               [get]
                                                [/version]          []               [get]
                                                [/version]          []               [get]
$ kubectl auth can-i --list --no-headers
*.*                                             []             []    [*]
                                                [*]            []    [*]
selfsubjectreviews.authentication.k8s.io        []             []    [create]
selfsubjectaccessreviews.authorization.k8s.io   []             []    [create]
selfsubjectrulesreviews.authorization.k8s.io    []             []    [create]
                                                [/api/*]       []    [get]
                                                [/api]         []    [get]
                                                [/apis/*]      []    [get]
                                                [/apis]        []    [get]
                                                [/healthz]     []    [get]
                                                [/healthz]     []    [get]
                                                [/livez]       []    [get]
                                                [/livez]       []    [get]
                                                [/openapi/*]   []    [get]
                                                [/openapi]     []    [get]
                                                [/readyz]      []    [get]
                                                [/readyz]      []    [get]
                                                [/version/]    []    [get]
                                                [/version/]    []    [get]
                                                [/version]     []    [get]
                                                [/version]     []    [get]

kubectl auth whoami

$ kubectl auth whoami
ATTRIBUTE   VALUE
Username    kalle
Groups      [Everyone DEP_Platform SVC_Kubernetes_clusteradmin system:authenticated]
$ kubectl auth whoami -o yaml
apiVersion: authentication.k8s.io/v1
kind: SelfSubjectReview
metadata:
  creationTimestamp: "2024-03-25T15:38:47Z"
status:
  userInfo:
    groups:
    - Everyone
    - DEP_Platform
    - SVC_Kubernetes_clusteradmin
    - system:authenticated
    username: kalle
$ kubectl auth whoami -o json
{
  "apiVersion": "authentication.k8s.io/v1",
  "kind": "SelfSubjectReview",
  "metadata": {
    "creationTimestamp": "2024-03-25T15:38:47Z"
  },
  "status": {
    "userInfo": {
      "groups": [
        "Everyone",
        "DEP_Platform",
        "SVC_Kubernetes_clusteradmin",
        "system:authenticated"
      ],
      "username": "kalle"
    }
  }
}

kubectl auth reconcile

$ kubectl auth reconcile -f clusterrolebinding.yaml
clusterrolebinding.rbac.authorization.k8s.io/oidc-cluster-admin reconciled
$ kubectl auth reconcile -f clusterrolebinding.yaml --dry-run=client
clusterrolebinding.rbac.authorization.k8s.io/oidc-cluster-admin reconciled (dry run)
$ kubectl auth reconcile -f clusterrolebinding.yaml --dry-run=server
error: --dry-run=server for command reconcile is not supported yet

Current Behavior

Currently everything is just single-colored.

Context

Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.

  • Operating System: linux
  • kubectl version: v1.29.3
  • kubecolor version: v0.2.2
@applejag applejag added the enhancement New feature or request label Mar 25, 2024
@applejag applejag added the good first issue Good for newcomers label Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant