-
Notifications
You must be signed in to change notification settings - Fork 453
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 dynamic data source #1103
Add dynamic data source #1103
Conversation
return nil | ||
} | ||
|
||
func filterObjectsByName(d *schema.ResourceData, meta interface{}, matches []tags.AttachedObjects) (string, 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.
Doing a quick scan of this code. This function appears to return the first regex match. But because it is a regex, couldn't it match more than one object? Should the function collect all the matches and emit an error if more than one is matched?
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.
It could. It was actually purposeful at first, but after your comment and talking to @koikonom, I realized it was a very bad idea. Thank you for bringing me to my senses!
Travis fails because you need to run |
cb9a1d8
to
471594d
Compare
471594d
to
4bd58e9
Compare
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.
minor typos
@@ -52,10 +52,10 @@ func dataSourceVSphereDynamicRead(d *schema.ResourceData, meta interface{}) erro | |||
} | |||
switch { | |||
case len(filtered) < 1: | |||
return fmt.Errorf("no matches resources found") | |||
return fmt.Errorf("no matcheing resources found") |
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.
return fmt.Errorf("no matcheing resources found") | |
return fmt.Errorf("no matching resources found") |
case len(filtered) > 1: | ||
log.Printf("dataSourceVSphereDynamic: Multiple matches found: %v", filtered) | ||
return fmt.Errorf("multiple object match the supplied criteria") | ||
return fmt.Errorf("multiple objecst match the supplied criteria") |
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.
return fmt.Errorf("multiple objecst match the supplied criteria") | |
return fmt.Errorf("multiple objects match the supplied criteria") |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks! |
This adds a special type of data source that can be used to find the ID of any tagged managed object.
Addresses #937