From 7fe31eac2658d45327dd4c976ce8b33812ce334f Mon Sep 17 00:00:00 2001 From: Hamza Tahir Date: Sun, 27 Oct 2024 19:47:39 +0100 Subject: [PATCH] Validate service connector type before auth method --- internal/provider/validation.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/internal/provider/validation.go b/internal/provider/validation.go index ba6ce8e..ede4128 100644 --- a/internal/provider/validation.go +++ b/internal/provider/validation.go @@ -68,6 +68,20 @@ var ( func validateServiceConnector(d *schema.ResourceData) error { connectorType := d.Get("type").(string) + + // Validate connector type first + validType := false + for _, t := range validConnectorTypes { + if t == connectorType { + validType = true + break + } + } + if !validType { + return fmt.Errorf("invalid connector type %q. Valid types are: %s", + connectorType, strings.Join(validConnectorTypes, ", ")) + } + authMethod := d.Get("auth_method").(string) // Validate auth method for connector type