-
Notifications
You must be signed in to change notification settings - Fork 292
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
Add the ability to attach host IDs directly to targets #910
base: main
Are you sure you want to change the base?
Conversation
Looks like the failing test: |
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.
These are more nitpicky suggestions than anything. Feel free to take them or close them out. Everything else looks okay though.
@@ -418,6 +420,73 @@ func (c *Client) AddHostSets(ctx context.Context, targetId string, version uint3 | |||
return target, nil | |||
} | |||
|
|||
func (c *Client) AddHosts(ctx context.Context, targetId string, version uint32, hostIds []string, opt ...Option) (*TargetUpdateResult, error) { |
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.
I feel like a note on what is happening here would be useful, especially since it is public. :) But not needed.
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.
Yeah that's fair, although given it's automatically generated there's some work involved to have anything meaningful added.
if api.AsServerError(existingErr) != nil { | ||
return nil, fmt.Errorf("error from controller when performing initial check-and-set read: %w", existingErr) | ||
} | ||
return nil, fmt.Errorf("error performing initial check-and-set read: %w", existingErr) |
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.
Why do some errors use fmt.Errorf
and some errors use errors.
?
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.
Generally if there are no formatting directives errors.New is used. Within internal
there is a separate errors
package that is used for some types of errors.
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.
Ah, previously I would wrap something like fmt.Sprintf
in errors.New
or errors.WithMsg()
Gotchya though
|
||
opts, apiOpts := getOpts(opt...) | ||
|
||
if version == 0 { |
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.
Would it be possible to take some of these validation steps out of Add, Set, and Remove hosts into their own functions? It would make the functions quite a bit smaller and reduce the repeating code.
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.
Yeah it might be. Since it's all autogenerated repeating code is really "code in one place that gets slotted in" but from a cleanliness perspective it might be nice.
helpStr = base.WrapForHelpText([]string{ | ||
"Usage: boundary target set-hosts [options] [args]", | ||
"", | ||
" This command allows setting the complete set of host resources on a target resource. Example:", |
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 could just be my confusion, but it may be good to add how this is different than add?
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.
Yeah it's subtle, but see how it says "setting the complete set of host resources" vs. "adding host resources".
Co-authored-by: hashicorp-tsccr[bot] <hashicorp-tsccr[bot]@users.noreply.github.com>
No description provided.