Skip to content

Commit

Permalink
fix: change validation to generic val
Browse files Browse the repository at this point in the history
  • Loading branch information
J0 committed Apr 19, 2024
1 parent cb071e2 commit 3dfd9cc
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions internal/utils/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ func (h *hookConfig) HandleHook(hookType string) error {
if h.URI == "" {
return fmt.Errorf("missing required field in config: auth.hook.%s.uri", hookType)
}
if err := validateHTTPHookURI(h.URI, hookType); err != nil {
if err := validateHookURI(h.URI, hookType); err != nil {
return err
}
var err error
Expand Down Expand Up @@ -855,13 +855,13 @@ func RemoveDuplicates(slice []string) (result []string) {
return result
}

func validateHTTPHookURI(uri, hookName string) error {
func validateHookURI(uri, hookName string) error {
parsed, err := url.Parse(uri)
if err != nil {
return errors.Errorf("failed to parse template url: %w", err)
}
if !(parsed.Scheme == "http" || parsed.Scheme == "https") {
return errors.Errorf("Invalid HTTP hook config: auth.hook.%v should be a HTTP or HTTPS URL", hookName)
if !(parsed.Scheme == "http" || parsed.Scheme == "https" || parsed.Scheme == "pg-functions") {
return errors.Errorf("Invalid HTTP hook config: auth.hook.%v should be a Postgres function URI, or a HTTP or HTTPS URL", hookName)
}
return nil
}

0 comments on commit 3dfd9cc

Please sign in to comment.