From c4757ce109e1badbf3f88dfd14d29c7638d24ada Mon Sep 17 00:00:00 2001 From: Tobias Trabelsi Date: Sun, 14 Aug 2022 20:53:18 +0200 Subject: [PATCH] #14 deprecate `migration_clone_addresse` in favor of `migration_clone_address` --- Makefile | 2 +- README.md | 2 +- docs/resources/repository.md | 3 ++- examples/main.tf | 2 +- examples/provider.tf | 2 +- gitea/resource_gitea_repository.go | 20 ++++++++++++++++++-- 6 files changed, 24 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 39f52c7..790ac6a 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ GOFMT_FILES?=$$(find . -name '*.go' |grep -v vendor) GOFMT ?= gofmt -s -VERSION = 0.7.2 +VERSION = 0.7.3 test: fmt-check go test -i $(TEST) || exit 1 diff --git a/README.md b/README.md index fcd0ce5..193de99 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ terraform { required_providers { gitea = { source = "Lerentis/gitea" - version = "0.7.2" + version = "0.7.3" } } } diff --git a/docs/resources/repository.md b/docs/resources/repository.md index d4b04ad..d706873 100644 --- a/docs/resources/repository.md +++ b/docs/resources/repository.md @@ -72,7 +72,8 @@ Need to exist in the gitea instance Need to exist in the gitea instance - `license` (String) The license under which the source code of this repository should be. Need to exist in the gitea instance -- `migration_clone_addresse` (String) +- `migration_clone_address` (String) +- `migration_clone_addresse` (String) DEPRECATED in favor of `migration_clone_address` - `migration_issue_labels` (Boolean) - `migration_lfs` (Boolean) - `migration_lfs_endpoint` (String) diff --git a/examples/main.tf b/examples/main.tf index d3fe2ac..05dd821 100644 --- a/examples/main.tf +++ b/examples/main.tf @@ -12,7 +12,7 @@ resource "gitea_repository" "mirror" { name = "terraform-provider-gitea-mirror" description = "Mirror of Terraform Provider" mirror = true - migration_clone_addresse = "https://git.uploadfilter24.eu/lerentis/terraform-provider-gitea.git" + migration_clone_address = "https://git.uploadfilter24.eu/lerentis/terraform-provider-gitea.git" migration_service = "gitea" migration_service_auth_token = var.gitea_mirror_token } diff --git a/examples/provider.tf b/examples/provider.tf index 24f0fca..ec315cc 100644 --- a/examples/provider.tf +++ b/examples/provider.tf @@ -2,7 +2,7 @@ terraform { required_providers { gitea = { source = "terraform.local/lerentis/gitea" - version = "0.7.2" + version = "0.8.0" } } } diff --git a/gitea/resource_gitea_repository.go b/gitea/resource_gitea_repository.go index 836065d..6436fcd 100644 --- a/gitea/resource_gitea_repository.go +++ b/gitea/resource_gitea_repository.go @@ -34,7 +34,8 @@ const ( repoAllowManualMerge string = "allow_manual_merge" repoAutodetectManualMerge string = "autodetect_manual_merge" repoMirror string = "mirror" - migrationCloneAddress string = "migration_clone_addresse" + migrationCloneAddresse string = "migration_clone_addresse" + migrationCloneAddress string = "migration_clone_address" migrationService string = "migration_service" migrationServiceAuthName string = "migration_service_auth_username" migrationServiceAuthPassword string = "migration_service_auth_password" @@ -89,10 +90,18 @@ func resourceRepoCreate(d *schema.ResourceData, meta interface{}) (err error) { } if (d.Get(repoMirror)).(bool) { + + var cloneAddr string + if d.Get(migrationCloneAddresse).(string) != "" { + cloneAddr = d.Get(migrationCloneAddresse).(string) + } else { + cloneAddr = d.Get(migrationCloneAddress).(string) + } + opts := gitea.MigrateRepoOption{ RepoName: d.Get(repoName).(string), RepoOwner: d.Get(repoOwner).(string), - CloneAddr: d.Get(migrationCloneAddress).(string), + CloneAddr: cloneAddr, Service: gitea.GitServiceType(d.Get(migrationService).(string)), Mirror: d.Get(repoMirror).(bool), Private: d.Get(repoPrivateFlag).(bool), @@ -445,6 +454,13 @@ func resourceGiteaRepository() *schema.Resource { Default: false, }, "migration_clone_addresse": { + Type: schema.TypeString, + Required: false, + Optional: true, + ForceNew: true, + Description: "DEPRECATED in favor of `migration_clone_address`", + }, + "migration_clone_address": { Type: schema.TypeString, Required: false, Optional: true,