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

Please enable yaml output for server reset-password #715

Closed
edgecode opened this issue Mar 17, 2024 · 6 comments · Fixed by #716 or #697
Closed

Please enable yaml output for server reset-password #715

edgecode opened this issue Mar 17, 2024 · 6 comments · Fixed by #716 or #697
Assignees
Labels

Comments

@edgecode
Copy link

edgecode commented Mar 17, 2024

TL;DR

$ hcloud version
hcloud 1.42.0

$ hcloud server reset-password --help
No option for YAML output :-(

Do I find the password in the server's description ... no:
$ hcloud server describe -o yaml SERVER_ID | grep -i pass

I have to resort to parsing the output, e.g.
$ hcloud server reset-password SERVER_ID | tail -n 1 | awk '{ print $NF }'

This is too fragile.
If the output format ever changes, code breaks.

Expected behavior

$ hcloud server reset-password --output yaml SERVER_ID

Thx :-)

@jooola jooola added the bug label Mar 18, 2024
@phm07 phm07 added feature and removed bug labels Mar 19, 2024
@phm07 phm07 self-assigned this Mar 19, 2024
@phm07
Copy link
Contributor

phm07 commented Mar 19, 2024

Thanks for your suggestion! It looks like a useful addition to me, I'll work on an implementation.

@phm07
Copy link
Contributor

phm07 commented Mar 19, 2024

I added the feature in #716

Can you please confirm that it works for you with

  • go install github.com/hetznercloud/cli/cmd/hcloud@reset-password-output-options
  • or go run github.com/hetznercloud/cli/cmd/hcloud@reset-password-output-options server reset-password <server> -o=yaml

@edgecode
Copy link
Author

I added the feature in #716

Wow, that was fast :-)
Thanks for your work!

Can you please confirm that it works for you with

I will.
However, I am not as fast as you are ;-)
And pretty busy atm.
I guess I can test the modified hcloud tool in the next few days, aiming at 2024-03-24.

Thanks again, phm07!
best,
edgecode

@edgecode
Copy link
Author

edgecode commented Mar 25, 2024

Tried to test, but failed due to my non-existant GO skills:
Unfortunalety I cannot dive into this atm.
@phm07 maybe you could give me a quick hint to set up GO correctly.

I am on a Ubuntu 22.04 machine.
It has GO 1.18 installed in Debian/Ubuntu's standard locations, e.g. /usr/{lib,share,bin}/go-1.18

When I run go install as a regular user, it downloads hclould code in ./go and I get:

/home/edge$ go install github.com/hetznercloud/cli/cmd/hcloud@reset-password-output-options
go/pkg/mod/github.com/hetznercloud/[email protected]/internal/cmd/iso/list.go:5:2: package slices is not in GOROOT (/usr/lib/go-1.18/src/slices)

I tried export GOROOT='/usr/lib/go-1.18:/home/edge/go' which did not help.
Reading the error message closer, I guess my GO installation is missing the slices package.
I will retry this evening and see how I can install that package.

@edgecode
Copy link
Author

I was able to get things working with go 1.22 :-)

Either I did not get the env vars or go.mod concept of go.
Or the package "slices" is not part of go's standard lib in version 1.18.
For the record: I installed the Canonical official snap package on my Ubuntu 22.04 machine which has many go version on board and defaults to go 1.22.

But back to business:
The modified hcloud cli works :-)
I do get YAML or JSON output when I reset a server's password.
And server reset-password --help lists the output options.

@phm07 Thanks again for your fast implementation of this small, but useful hcloud enhancment.

@apricote
Copy link
Member

Yea, slices was only added in Go 1.21, and that is the lowest version we currently support.

Great that it works for you!

I will re-open the issue until the PR is merged, @phm07 will be back next week to take care of that.

@apricote apricote reopened this Mar 26, 2024
@phm07 phm07 closed this as completed in #716 Apr 2, 2024
phm07 added a commit that referenced this issue Apr 2, 2024
This PR adds the ability to output the root password after a password
reset in JSON or YAML format.

Closes #715
phm07 pushed a commit that referenced this issue Apr 3, 2024
🤖 I have created a release *beep* *boop*
---


##
[1.43.0](v1.42.0...v1.43.0)
(2024-04-03)


### Features

* allow deletion of multiple resources at once
([#719](#719))
([3b896fe](3b896fe))
* improve missing argument error messages
([#711](#711))
([e7f9e74](e7f9e74))
* **server:** allow JSON & YAML output in reset-password
([#716](#716))
([373287b](373287b)),
closes [#715](#715)


### Bug Fixes

* removing last rule from firewall fails with invalid_input error
([#696](#696))
([acab17c](acab17c))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants