Uploaded image for project: 'OpenShift Request For Enhancement'
  1. OpenShift Request For Enhancement
  2. RFE-3594

Add option for YAML/JSON output for oc whoami

XMLWordPrintable

    • None
    • Product / Portfolio Work
    • None
    • False
    • Hide

      None

      Show
      None
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      As a user, I would like to see my group information with oc whoami so that I know which group or groups I'm a part of.

      Currently this is only possible with oc whoami -v 8 and look at the JSON payload

      $ oc whoami -v 8
      I0118 13:21:20.114032  544538 loader.go:374] Config loaded from file:  /home/chernand/.kube/config
      I0118 13:21:20.114270  544538 round_trippers.go:463] GET https://api.cluster1.aws.chx.cloud:6443/apis/user.openshift.io/v1/users/~
      I0118 13:21:20.114274  544538 round_trippers.go:469] Request Headers:
      I0118 13:21:20.114279  544538 round_trippers.go:473]     Accept: application/json, */*
      I0118 13:21:20.114283  544538 round_trippers.go:473]     User-Agent: oc/4.12.0 (linux/amd64) kubernetes/854f807
      I0118 13:21:20.114287  544538 round_trippers.go:473]     Authorization: Bearer <masked>
      I0118 13:21:20.431818  544538 round_trippers.go:574] Response Status: 200 OK in 317 milliseconds
      I0118 13:21:20.431834  544538 round_trippers.go:577] Response Headers:
      I0118 13:21:20.431839  544538 round_trippers.go:580]     Date: Wed, 18 Jan 2023 21:21:20 GMT
      I0118 13:21:20.431842  544538 round_trippers.go:580]     X-Kubernetes-Pf-Flowschema-Uid: 23b793d0-6d86-4d4f-89cc-bb6e19bd4ee2
      I0118 13:21:20.431846  544538 round_trippers.go:580]     X-Kubernetes-Pf-Flowschema-Uid: 23b793d0-6d86-4d4f-89cc-bb6e19bd4ee2
      I0118 13:21:20.431849  544538 round_trippers.go:580]     X-Kubernetes-Pf-Prioritylevel-Uid: 409664f9-9ef6-4cd8-bb11-e9338520f1ac
      I0118 13:21:20.431852  544538 round_trippers.go:580]     X-Kubernetes-Pf-Prioritylevel-Uid: 409664f9-9ef6-4cd8-bb11-e9338520f1ac
      I0118 13:21:20.431854  544538 round_trippers.go:580]     Audit-Id: f351228a-fb88-49ba-a031-00de799055a7
      I0118 13:21:20.431857  544538 round_trippers.go:580]     Audit-Id: f351228a-fb88-49ba-a031-00de799055a7
      I0118 13:21:20.431860  544538 round_trippers.go:580]     Cache-Control: no-cache, private
      I0118 13:21:20.431863  544538 round_trippers.go:580]     Cache-Control: no-cache, private
      I0118 13:21:20.431866  544538 round_trippers.go:580]     Content-Type: application/json
      I0118 13:21:20.431868  544538 round_trippers.go:580]     Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
      I0118 13:21:20.431871  544538 round_trippers.go:580]     Content-Length: 507
      I0118 13:21:20.431889  544538 request.go:1154] Response Body: {"kind":"User","apiVersion":"user.openshift.io/v1","metadata":{"name":"developer","uid":"7a0a12d1-4d10-4d07-a9de-134d970af0d0","resourceVersion":"31586","creationTimestamp":"2023-01-18T21:16:53Z","managedFields":[{"manager":"Go-http-client","operation":"Update","apiVersion":"user.openshift.io/v1","time":"2023-01-18T21:16:53Z","fieldsType":"FieldsV1","fieldsV1":{"f:identities":{}}}]},"identities":["htpasswd_provider:developer"],"groups":["bar","foo","system:authenticated","system:authenticated:oauth"]}
      developer
      

      It would be nice if this was built in to the command

      Example:

      $ oc whoami -o yaml
      

              gausingh@redhat.com Gaurav Singh
              rh-ee-chernand Christian Hernandez (Inactive)
              None
              Votes:
              5 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                None
                None