Skip to content

NO-JIRA: Display whoami information as JSON or YAML #1324

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

christianh814
Copy link

@christianh814 christianh814 commented Jan 19, 2023

Added an option -o or --output that displays the user information in YAML or JSON.

Closes: #1323

Signed-off-by: Christian Hernandez [email protected]

@openshift-ci openshift-ci bot requested review from ardaguclu and deads2k January 19, 2023 00:28
@christianh814
Copy link
Author

/retest-required

@christianh814 christianh814 marked this pull request as draft January 20, 2023 04:08
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 20, 2023
@christianh814 christianh814 changed the title added show-groups option to display group membership WIP: Display User information as JSON or YAML Jan 20, 2023
@christianh814 christianh814 marked this pull request as ready for review January 20, 2023 15:44
@openshift-ci openshift-ci bot requested review from mfojtik and soltysh January 20, 2023 15:44
@christianh814
Copy link
Author

/retest-required

Signed-off-by: Christian Hernandez <[email protected]>

changing to output of json or yaml

Signed-off-by: Christian Hernandez <[email protected]>

updated to use output of yaml or json

Signed-off-by: Christian Hernandez <[email protected]>

added the GVK to the output

Signed-off-by: Christian Hernandez <[email protected]>
@christianh814 christianh814 changed the title WIP: Display User information as JSON or YAML Display whoami information as JSON or YAML Jan 20, 2023
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 20, 2023
@christianh814
Copy link
Author

/retest-required

1 similar comment
@christianh814
Copy link
Author

/retest-required

@christianh814
Copy link
Author

/test e2e-aws-ovn-serial

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 20, 2023

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: christianh814
Once this PR has been reviewed and has the lgtm label, please assign deads2k for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 21, 2023

@christianh814: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-aws-ovn-upgrade 25e26e6 link true /test e2e-aws-ovn-upgrade
ci/prow/e2e-aws-ovn-serial 25e26e6 link true /test e2e-aws-ovn-serial

Full PR test history. Your PR dashboard.

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. I understand the commands that are listed here.

@openshift-bot
Copy link
Contributor

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

@openshift-ci openshift-ci bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jun 19, 2023
@christianh814
Copy link
Author

/remove-lifecycle stale

@openshift-ci openshift-ci bot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jun 19, 2023
@openshift-bot
Copy link
Contributor

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

@openshift-ci openshift-ci bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Sep 18, 2023
@openshift-bot
Copy link
Contributor

Stale issues rot after 30d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle rotten
/remove-lifecycle stale

@openshift-ci openshift-ci bot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Oct 19, 2023
@christianh814
Copy link
Author

/remove-lifecycle rotten

@christianh814
Copy link
Author

/remove-lifecycle stale

@openshift-ci openshift-ci bot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 17, 2024
@openshift-bot
Copy link
Contributor

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

@openshift-ci openshift-ci bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Apr 16, 2024
@christianh814
Copy link
Author

/remove-lifecycle stale.

@openshift-bot
Copy link
Contributor

Stale issues rot after 30d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle rotten
/remove-lifecycle stale

@openshift-ci openshift-ci bot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels May 17, 2024
@christianh814
Copy link
Author

/remove-lifecycle rotten

@openshift-ci openshift-ci bot removed the lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. label May 17, 2024
@openshift-bot
Copy link
Contributor

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

@openshift-ci openshift-ci bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Aug 15, 2024
@christianh814
Copy link
Author

/remove-lifecycle stale

@openshift-ci openshift-ci bot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Aug 15, 2024
@openshift-bot
Copy link
Contributor

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

@openshift-ci openshift-ci bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Nov 14, 2024
@christianh814
Copy link
Author

/remove-lifecycle stale

@openshift-ci openshift-ci bot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Nov 18, 2024
@openshift-bot
Copy link
Contributor

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

@openshift-ci openshift-ci bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Feb 17, 2025
@christianh814
Copy link
Author

/remove-lifecycle stale

@openshift-ci openshift-ci bot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Feb 18, 2025
@vrutkovs
Copy link
Member

/retitle NO-JIRA: Display whoami information as JSON or YAML
/refresh

@ardaguclu PTAL

@openshift-ci openshift-ci bot changed the title Display whoami information as JSON or YAML NO-JIRA: Display whoami information as JSON or YAML May 16, 2025
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label May 16, 2025
@openshift-ci-robot
Copy link

@christianh814: This pull request explicitly references no jira issue.

In response to this:

Added an option -o or --output that displays the user information in YAML or JSON.

Closes: #1323

Signed-off-by: Christian Hernandez [email protected]

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 openshift-eng/jira-lifecycle-plugin repository.

@kaovilai
Copy link
Member

@vrutkovs fyi jira exists here: https://issues.redhat.com/browse/RFE-3594 should we use that?

@christianh814
Copy link
Author

/retitle NO-JIRA: Display whoami information as JSON or YAML /refresh

@ardaguclu PTAL

@vrutkovs JIRA was created 2 years ago https://issues.redhat.com/browse/RFE-3594

@vrutkovs
Copy link
Member

This RFE seems deferred, so we'll need a bug or a task ticket for this. In any case, JIRA ticket here is required if we want to backport it - and it can be done later

Copy link
Member

@ardaguclu ardaguclu left a comment

Choose a reason for hiding this comment

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

Thank you for this PR. However, SelfSubjectReview takes precedence over User object in OpenShift. So that this PR needs to be modified accordingly.

@@ -153,14 +164,34 @@ func (o *WhoAmIOptions) Run() error {
}
fmt.Fprintf(o.Out, "%s\n", consoleUrl)
return nil
}
case o.Output == "yaml":
u, err := o.UserInterface.Users().Get(context.TODO(), "~", metav1.GetOptions{})
Copy link
Member

@ardaguclu ardaguclu May 20, 2025

Choose a reason for hiding this comment

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

SelfSubjectReview needs to take precedence over UserInterface (logic

res, err := o.AuthV1Client.SelfSubjectReviews().Create(context.TODO(), &v1.SelfSubjectReview{}, metav1.CreateOptions{})
if err == nil {
me := &userv1.User{
ObjectMeta: metav1.ObjectMeta{
Name: res.Status.UserInfo.Username,
},
Groups: res.Status.UserInfo.Groups,
}
fmt.Fprintf(o.Out, "%s\n", me.Name)
return me, nil
} else {
klog.V(2).Infof("selfsubjectreview request error %v, falling back to user object", err)
}
me, err := o.UserInterface.Users().Get(context.TODO(), "~", metav1.GetOptions{})
if err == nil {
fmt.Fprintf(o.Out, "%s\n", me.Name)
}
return me, err
). Actually, there is no need to duplicate the effort. Why can't we print what we get in WhoAmI function.

}
fmt.Fprintf(o.Out, "%s\n", string(y))
return nil
case o.Output == "json":
Copy link
Member

Choose a reason for hiding this comment

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

@@ -47,6 +49,8 @@ type WhoAmIOptions struct {
ShowContext bool
ShowServer bool
ShowConsoleUrl bool
ShowGroups bool
Copy link
Member

Choose a reason for hiding this comment

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

Unused and not related to this PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RFE-3594: Whoami should show group memberships
6 participants