sudo87 commented on code in PR #337:
URL: 
https://github.com/apache/cloudstack-terraform-provider/pull/337#discussion_r3921305167


##########
cloudstack/resource_cloudstack_host.go:
##########
@@ -55,7 +55,7 @@ func resourceCloudStackHost() *schema.Resource {
 
                                        sort.Strings(validHypervisors)
 
-                                       if sort.SearchStrings(validHypervisors, 
v.(string)) >= len(validHypervisors) {
+                                       if i := 
sort.SearchStrings(validHypervisors, v.(string)); i >= len(validHypervisors) || 
validHypervisors[i] != v.(string) {
                                                errors = append(errors, 
fmt.Errorf("%q must be one of %v", k, validHypervisors))
                                        }
                                        return

Review Comment:
   Rather than hand-rolling the fix with sort.SearchStrings + an index check, 
could you use: validation.StringInSlice(validHypervisors, false)
   
   ```suggestion
   ValidateFunc: validation.StringInSlice([]string{"xenserver", "kvm", 
"vmware", "baremetal", "simulator"}, false),
   ```
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to