From 895c513f20dcfa85ff29d0a46359a54147c9e2cb Mon Sep 17 00:00:00 2001 From: joel Date: Wed, 10 Apr 2024 07:46:48 +0800 Subject: [PATCH 1/2] feat: add aliases --- internal/conf/configuration.go | 2 +- internal/conf/configuration_test.go | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/conf/configuration.go b/internal/conf/configuration.go index 7a5e36b18..420c84d26 100644 --- a/internal/conf/configuration.go +++ b/internal/conf/configuration.go @@ -505,7 +505,7 @@ func (e *ExtensibilityPointConfiguration) ValidateExtensibilityPoint() error { return validatePostgresPath(u) case "http": hostname := u.Hostname() - if hostname == "localhost" || hostname == "127.0.0.1" || hostname == "::1" || hostname == "host.docker.internal" { + if hostname == "localhost" || hostname == "127.0.0.1" || hostname == "::1" || hostname == "host.docker.internal" || hostname == "kong" || hostname == "edge_runtime" { return validateHTTPHookSecrets(e.HTTPHookSecrets) } return fmt.Errorf("only localhost, 127.0.0.1, and ::1 are supported with http") diff --git a/internal/conf/configuration_test.go b/internal/conf/configuration_test.go index eaef0335d..e8a65c9b1 100644 --- a/internal/conf/configuration_test.go +++ b/internal/conf/configuration_test.go @@ -163,6 +163,8 @@ func TestValidateExtensibilityPointURI(t *testing.T) { {desc: "Another Valid URI", uri: "pg-functions://postgres/user_management/add_user", expectError: false}, {desc: "Another Valid URI", uri: "pg-functions://postgres/MySpeCial/FUNCTION_THAT_YELLS_AT_YOU", expectError: false}, {desc: "Valid HTTP URI", uri: "http://localhost/functions/v1/custom-sms-sender", expectError: false}, + {desc: "Valid localhost URI with kong alias", uri: "http://kong:8000/functions/v1/custom-sms-sender", expectError: false}, + {desc: "Valid localhost URI with edge_runtime", uri: "http://edge_runtime:8000/functions/v1/custom-sms-sender", expectError: false}, // Negative test cases {desc: "Invalid HTTP URI", uri: "http://asdfgggg.website.co/functions/v1/custom-sms-sender", expectError: true}, From b86179f268a4e22f0deece66f7b60c202bfe59ea Mon Sep 17 00:00:00 2001 From: Joel Lee Date: Wed, 10 Apr 2024 07:55:41 +0800 Subject: [PATCH 2/2] fix: update example --- internal/conf/configuration_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/conf/configuration_test.go b/internal/conf/configuration_test.go index e8a65c9b1..7dc6d58e0 100644 --- a/internal/conf/configuration_test.go +++ b/internal/conf/configuration_test.go @@ -164,7 +164,7 @@ func TestValidateExtensibilityPointURI(t *testing.T) { {desc: "Another Valid URI", uri: "pg-functions://postgres/MySpeCial/FUNCTION_THAT_YELLS_AT_YOU", expectError: false}, {desc: "Valid HTTP URI", uri: "http://localhost/functions/v1/custom-sms-sender", expectError: false}, {desc: "Valid localhost URI with kong alias", uri: "http://kong:8000/functions/v1/custom-sms-sender", expectError: false}, - {desc: "Valid localhost URI with edge_runtime", uri: "http://edge_runtime:8000/functions/v1/custom-sms-sender", expectError: false}, + {desc: "Valid localhost URI with edge_runtime", uri: "http://edge_runtime:54321/functions/v1/custom-sms-sender", expectError: false}, // Negative test cases {desc: "Invalid HTTP URI", uri: "http://asdfgggg.website.co/functions/v1/custom-sms-sender", expectError: true},