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

Retrieve agent id command #154

Merged
merged 2 commits into from
Dec 15, 2022
Merged

Retrieve agent id command #154

merged 2 commits into from
Dec 15, 2022

Conversation

nelsonkopliku
Copy link
Member

@nelsonkopliku nelsonkopliku commented Dec 14, 2022

This PR adds a command to reliably retrieve the agent id from a trento-agent installation.

Here's the usage

$ trento-agent id
f6fe2f71-42cc-482f-877f-00d9b4592d83

And here's a sample output in case of an error

$ trento-agent id
FATA[0000] Failed to get Agent id: open /etc/machine-idz: no such file or directory

@nelsonkopliku nelsonkopliku changed the title Retrieve agent Retrieve agent id command Dec 14, 2022
@nelsonkopliku nelsonkopliku self-assigned this Dec 14, 2022
@nelsonkopliku nelsonkopliku added the enhancement New feature or request label Dec 14, 2022
@nelsonkopliku nelsonkopliku force-pushed the retrieve-agent-id branch 2 times, most recently from a06eb54 to 1aa075a Compare December 14, 2022 13:58
@nelsonkopliku nelsonkopliku marked this pull request as ready for review December 14, 2022 14:04
Copy link
Contributor

@dottorblaster dottorblaster left a comment

Choose a reason for hiding this comment

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

Just a tiny comment then we can merge

cmd/id.go Outdated Show resolved Hide resolved
Copy link
Contributor

@dottorblaster dottorblaster left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@arbulu89 arbulu89 left a comment

Choose a reason for hiding this comment

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

I would remove the added documentation.
Besides that, good to go

README.md Outdated Show resolved Hide resolved
cmd/id.go Outdated Show resolved Hide resolved
cmd/id.go Outdated Show resolved Hide resolved
RunE: func(cmd *cobra.Command, args []string) error {
agentID, err := agent.GetAgentID()
if err != nil {
return err
Copy link
Member Author

@nelsonkopliku nelsonkopliku Dec 14, 2022

Choose a reason for hiding this comment

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

For completeness: as per suggestion I changed from previous proposal that has log.Fatal("Failed to get Agent id: ", err).
This changes the output in error scenario from:

FATA[0000] Failed to get Agent id: open /etc/machine-idz: no such file or directory

to

Error: open /etc/machine-idz: no such file or directory
Usage: ...
Flags: ...
Global Flags: ...

Error: open /etc/machine-idz: no such file or directory

Copy link
Member Author

Choose a reason for hiding this comment

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

@CDimonaco are we good with the changes? Anything else is needed prior merging?

Copy link
Contributor

@arbulu89 arbulu89 left a comment

Choose a reason for hiding this comment

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

Thanks @nelsonkopliku ,
Perfect now from my side

@nelsonkopliku nelsonkopliku merged commit b78fad3 into main Dec 15, 2022
@nelsonkopliku nelsonkopliku deleted the retrieve-agent-id branch December 15, 2022 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

Successfully merging this pull request may close these issues.

4 participants