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

Allow to override default username via command line #15411

Merged

Conversation

arixmkii
Copy link
Contributor

Fixes #15402

Registers additional flag to override username during machine init.

Signed-off-by: Arthur Sengileyev arthur.sengileyev@gmail.com

Does this PR introduce a user-facing change?

Added `--username` flag to override username used for initializing podman machine with `podman init` command.

@openshift-ci openshift-ci bot added release-note do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels Aug 22, 2022
@arixmkii
Copy link
Contributor Author

arixmkii commented Aug 22, 2022

Draft because I first want to double check it with my custom Windows Qemu branch (#13006) as this code around command parsing flags is still too magical for me.

@@ -89,6 +88,10 @@ func init() {
)
_ = flags.MarkHidden("reexec")

UsernameFlagName := "username"
flags.StringVar(&initOpts.Username, UsernameFlagName, cfg.Machine.User, "Username used in qcow image")
Copy link
Member

Choose a reason for hiding this comment

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

Should this be cfg.Config.Machine.User instead of cfg.Machine.User, given that's what the removed bit used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tested this with cherry-pick (w/o additional alterations). And it resulted with
"RemoteUsername": "user", in json config when called w/o explicit value and with "RemoteUsername": "core", giving --username core in the command line. I will investigate the code to understand better how it works. Wrote it this way because lines below references config settings with cfg.Machine.* - w/o additional .Config. And it was the only line with cfg.Config.

I will take a more detailed look before implementing this change. Keeping the draft for now.

Copy link
Contributor Author

@arixmkii arixmkii Aug 30, 2022

Choose a reason for hiding this comment

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

If I read this line correctly:

*config.Config

Then Config is just expanded/blended into PodmanConfig, so, we can use it bypassing one dereference. My knowledge of advanced Go features is still limited. But at least VS Code code navigation navigates to the same place with .cfg.Machine and .cfg.Config.Machine. And, as I mentioned above, this worked in build the same way I described here, so, I guess this is correct.

@mheon Do you still insist on changing this (and only this) line?

Updates: also rebased PR to latest main.

@mheon
Copy link
Member

mheon commented Aug 22, 2022

/approve

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 22, 2022
@mheon
Copy link
Member

mheon commented Aug 23, 2022

Tests are complaining the flag needs to be added to the manpages:

xref-helpmsgs-manpages: 'podman machine init --help' lists '--username', which is not in docs/source/markdown/podman-machine-init.1.md

@arixmkii
Copy link
Contributor Author

Added docs in a separate commit. Can squash them if needed/rebase to lasest and squash if needed.

@arixmkii arixmkii marked this pull request as ready for review August 30, 2022 09:52
@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 Aug 30, 2022
@rhatdan
Copy link
Member

rhatdan commented Aug 30, 2022

Could you add a test to pkg/machine/e2e/init_test.go

Add --username foobar and then inspect the machine to verify "RemoteUsername": "foobar"

@arixmkii
Copy link
Contributor Author

Will add test, squash and force push again.

Signed-off-by: Arthur Sengileyev <arthur.sengileyev@gmail.com>
@arixmkii
Copy link
Contributor Author

sys podman ubuntu-2204 rootless host failed

I believe this one is flaky. IIRC it is exactly the same, which also failed first in #15404

@rhatdan
Copy link
Member

rhatdan commented Aug 31, 2022

/approve
LGTM
@containers/podman-maintainers PTAL

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Aug 31, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: arixmkii, mheon, rhatdan

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

The pull request process is described 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

@mheon
Copy link
Member

mheon commented Aug 31, 2022

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Aug 31, 2022
@openshift-merge-robot openshift-merge-robot merged commit 55710d8 into containers:main Aug 31, 2022
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 20, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 20, 2023
@arixmkii arixmkii deleted the override_default_username branch March 1, 2024 13:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. release-note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow to override remote user in machine init
4 participants