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

Add the ability to attach host IDs directly to targets #910

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jefferai
Copy link
Member

@jefferai jefferai commented Feb 4, 2021

No description provided.

@jimlambrt
Copy link
Collaborator

Looks like the failing test: TestSession_Create/empty-hostSetId could be fixed by a merge from main.

@jefferai jefferai modified the milestones: 0.1.6, 0.1.7, 0.1.8 Feb 10, 2021
Copy link
Contributor

@schristoff schristoff left a 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) {
Copy link
Contributor

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.

Copy link
Member Author

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)
Copy link
Contributor

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.?

Copy link
Member Author

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.

Copy link
Contributor

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 {
Copy link
Contributor

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.

Copy link
Member Author

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:",
Copy link
Contributor

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?

Copy link
Member Author

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".

@malnick malnick removed this from the 0.1.8 milestone Mar 9, 2021
@jefferai jefferai added this to the deferred milestone Mar 24, 2021
louisruch pushed a commit that referenced this pull request Apr 7, 2024
Co-authored-by: hashicorp-tsccr[bot] <hashicorp-tsccr[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants