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 30, 2024
1 parent 1d6c127 commit 1a40588
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 @@ -879,13 +879,13 @@ func loadEnvIfExists(path string) error {
}
}

Check failure on line 880 in internal/utils/config.go

View workflow job for this annotation

GitHub Actions / Start

missing return

Check failure on line 880 in internal/utils/config.go

View workflow job for this annotation

GitHub Actions / Lint

missing return) (typecheck)

Check failure on line 880 in internal/utils/config.go

View workflow job for this annotation

GitHub Actions / Lint

missing return) (typecheck)

Check failure on line 880 in internal/utils/config.go

View workflow job for this annotation

GitHub Actions / Lint

missing return) (typecheck)

Check failure on line 880 in internal/utils/config.go

View workflow job for this annotation

GitHub Actions / Lint

missing return (typecheck)

Check failure on line 880 in internal/utils/config.go

View workflow job for this annotation

GitHub Actions / Test

missing return

Check failure on line 880 in internal/utils/config.go

View workflow job for this annotation

GitHub Actions / Test

missing return

Check failure on line 880 in internal/utils/config.go

View workflow job for this annotation

GitHub Actions / Test

missing return

Check failure on line 880 in internal/utils/config.go

View workflow job for this annotation

GitHub Actions / Test

missing return

Check failure on line 880 in internal/utils/config.go

View workflow job for this annotation

GitHub Actions / Test

missing return

Check failure on line 880 in internal/utils/config.go

View workflow job for this annotation

GitHub Actions / Test

missing return

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 1a40588

Please sign in to comment.