-
Notifications
You must be signed in to change notification settings - Fork 75
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
Added server {set,get}-user-data subcommand #105
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for submitting a PR there are two changes that do need to be made before I can merge this in
cmd/server.go
Outdated
Short: "Set the user-data of a server", | ||
Args: func(cmd *cobra.Command, args []string) error { | ||
if len(args) < 2 { | ||
return errors.New("please provide a instanceID and userData") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The user-data should be a flag that is passed in so it follows the same consistency as other calls.
Label is a good example to follow
https://github.com/vultr/vultr-cli/blob/master/cmd/server.go#L43
https://github.com/vultr/vultr-cli/blob/master/cmd/server.go#L342
cmd/server.go
Outdated
os.Exit(1) | ||
} | ||
|
||
_, _ = os.Stdout.Write(rawData) // For proper handling of binary user-data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should have its own function in printer/server.go
https://github.com/vultr/vultr-cli/blob/master/cmd/printer/server.go
User-data can be quite lengthy and it doesn't make much sense specifying it as a param or flag. (Actually, I tried to replicate existing code in handling the user-data of baremetal servers in this PR in terms of consistency.) The same for the printer part. Maybe a better design is to just read user-data from stdin or a file, which is specified as a flag? |
I didn't notice how it is currently being done in bare-metal so we can leave it as STDIN. As for the printer I will take another look - baremetal is using https://github.com/vultr/vultr-cli/blob/master/cmd/printer/userData.go to decode the data but it may be good to revisit this behavior and change it for the better |
There's some inherent inconsistency in the govultr library itself. For SetUserData part, it takes raw input and encodes it, however for the GetUserData part it returns the encoded data as is. Moreover it asumes that user-data is of string type, which is not necessarily true. |
Agreed - the We will make this change in GoVultr so that the behavior is more streamlined and consistent. |
@NickCao We released GoVultr 0.5.0 which changes the |
…rdata command more consistent
I moved the userdata part to it's own subcommand, and added a flag to specify the userdata (to read). |
It'd be great to be able to refer to a file in order to set user-data, as mentioned in one of the initial comments |
Description
Related Issues
Checklist: