Skip to content

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

Draft
jefferai wants to merge 1 commit into
mainfrom
ICU-1063-target-hosts
Draft

Add the ability to attach host IDs directly to targets#910
jefferai wants to merge 1 commit into
mainfrom
ICU-1063-target-hosts

Conversation

@jefferai
Copy link
Copy Markdown
Member

@jefferai jefferai commented Feb 4, 2021

No description provided.

@jimlambrt
Copy link
Copy Markdown
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
Copy Markdown

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

Comment thread api/targets/target.gen.go
return target, nil
}

func (c *Client) AddHosts(ctx context.Context, targetId string, version uint32, hostIds []string, opt ...Option) (*TargetUpdateResult, error) {
Copy link
Copy Markdown

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
Copy Markdown
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.

Comment thread api/targets/target.gen.go
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
Copy Markdown

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
Copy Markdown
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
Copy Markdown

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

Comment thread api/targets/target.gen.go

opts, apiOpts := getOpts(opt...)

if version == 0 {
Copy link
Copy Markdown

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
Copy Markdown
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
Copy Markdown

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
Copy Markdown
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