From 13d3ed85adee2b632a6f866492e6d4bc1a25c0d2 Mon Sep 17 00:00:00 2001 From: Tobias Trabelsi Date: Sat, 12 Nov 2022 20:56:48 +0100 Subject: [PATCH] removed unintuitive fallback if repo owner does not exist --- Makefile | 2 +- README.md | 2 +- docs/index.md | 2 +- examples/provider.tf | 2 +- examples/provider/provider.tf | 2 +- gitea/resource_gitea_repository.go | 18 ++---------------- 6 files changed, 7 insertions(+), 21 deletions(-) diff --git a/Makefile b/Makefile index db57ba4..fd641ad 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ GOFMT_FILES?=$$(find . -name '*.go' |grep -v vendor) GOFMT ?= gofmt -s -VERSION = 0.11.0 +VERSION = 0.11.1 test: fmt-check go test -i $(TEST) || exit 1 diff --git a/README.md b/README.md index 6ac8167..07892f9 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ terraform { required_providers { gitea = { source = "Lerentis/gitea" - version = "0.11.0" + version = "0.11.1" } } } diff --git a/docs/index.md b/docs/index.md index 6321d65..40087d4 100644 --- a/docs/index.md +++ b/docs/index.md @@ -17,7 +17,7 @@ terraform { required_providers { gitea = { source = "Lerentis/gitea" - version = "0.11.0" + version = "0.11.1" } } } diff --git a/examples/provider.tf b/examples/provider.tf index 5e09406..9d46388 100644 --- a/examples/provider.tf +++ b/examples/provider.tf @@ -2,7 +2,7 @@ terraform { required_providers { gitea = { source = "terraform.local/lerentis/gitea" - version = "0.11.0" + version = "0.11.1" } } } diff --git a/examples/provider/provider.tf b/examples/provider/provider.tf index 1ede8a9..8b26bc4 100644 --- a/examples/provider/provider.tf +++ b/examples/provider/provider.tf @@ -2,7 +2,7 @@ terraform { required_providers { gitea = { source = "Lerentis/gitea" - version = "0.11.0" + version = "0.11.1" } } } diff --git a/gitea/resource_gitea_repository.go b/gitea/resource_gitea_repository.go index 9862b43..7a0220a 100644 --- a/gitea/resource_gitea_repository.go +++ b/gitea/resource_gitea_repository.go @@ -78,16 +78,6 @@ func resourceRepoCreate(d *schema.ResourceData, meta interface{}) (err error) { client := meta.(*gitea.Client) var repo *gitea.Repository - var resp *gitea.Response - var orgRepo bool - - _, resp, err = client.GetOrg(d.Get(repoOwner).(string)) - - if resp.StatusCode == 404 { - orgRepo = false - } else { - orgRepo = true - } if (d.Get(repoMirror)).(bool) { @@ -144,15 +134,11 @@ func resourceRepoCreate(d *schema.ResourceData, meta interface{}) (err error) { TrustModel: "default", } - if orgRepo { - repo, _, err = client.CreateOrgRepo(d.Get(repoOwner).(string), opts) - } else { - repo, _, err = client.CreateRepo(opts) - } + repo, _, err = client.CreateOrgRepo(d.Get(repoOwner).(string), opts) } if err != nil { - return + return err } err = setRepoResourceData(repo, d)