From edfd4e2e069be2795d8a6c964b662612a5da524d Mon Sep 17 00:00:00 2001 From: Tobias Trabelsi Date: Thu, 4 Aug 2022 18:23:41 +0200 Subject: [PATCH] #7 fail gracefully if gitea url violates RFC 2606 --- Makefile | 2 +- README.md | 2 +- examples/provider.tf | 2 +- gitea/provider.go | 3 +++ 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index dc91e40..e2a15fa 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ GOFMT_FILES?=$$(find . -name '*.go' |grep -v vendor) GOFMT ?= gofmt -s -VERSION = 0.6.1 +VERSION = 0.7.0 test: fmt-check go test -i $(TEST) || exit 1 diff --git a/README.md b/README.md index fb52c6e..3f7670a 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ terraform { required_providers { gitea = { source = "Lerentis/gitea" - version = "0.6.1" + version = "0.7.0" } } } diff --git a/examples/provider.tf b/examples/provider.tf index 0e08f75..0d34bb4 100644 --- a/examples/provider.tf +++ b/examples/provider.tf @@ -2,7 +2,7 @@ terraform { required_providers { gitea = { source = "terraform.local/lerentis/gitea" - version = "0.6.1" + version = "0.7.0" } } } diff --git a/gitea/provider.go b/gitea/provider.go index 11daf15..32c5da6 100644 --- a/gitea/provider.go +++ b/gitea/provider.go @@ -118,5 +118,8 @@ func validateAPIURLVersion(value interface{}, key string) (ws []string, es []err if strings.HasSuffix(v, "/api/v1") || strings.HasSuffix(v, "/api/v1/") { es = append(es, fmt.Errorf("terraform-gitea-provider base URL format is incorrect; Please leave out API Path %s", v)) } + if strings.Contains(v, "localhost") && strings.Contains(v, ".") { + es = append(es, fmt.Errorf("terraform-gitea-provider base URL violates RFC 2606; Please do not define a subdomain for localhost!")) + } return } -- 2.45.2