From 948b20a6d272a3638b7c77fe3fa9416507edf880 Mon Sep 17 00:00:00 2001 From: ultimania Date: Wed, 31 May 2023 08:54:45 +0900 Subject: [PATCH 1/2] fixed conditions of migration --- Makefile | 2 +- README.md | 2 +- docs/index.md | 2 +- examples/provider.tf | 2 +- examples/provider/provider.tf | 2 +- gitea/resource_gitea_repository.go | 14 +++++++------- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 486f45c..803227b 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ KERNEL?=$$(uname -s | tr '[:upper:]' '[:lower:]') GOFMT ?= gofmt -s -VERSION = 0.13.0 +VERSION = 0.14.0 test: fmt-check go test -i $(TEST) || exit 1 diff --git a/README.md b/README.md index 17d15ca..1e929aa 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ terraform { required_providers { gitea = { source = "Lerentis/gitea" - version = "0.13.0" + version = "0.14.0" } } } diff --git a/docs/index.md b/docs/index.md index 4a70051..72724de 100644 --- a/docs/index.md +++ b/docs/index.md @@ -17,7 +17,7 @@ terraform { required_providers { gitea = { source = "Lerentis/gitea" - version = "0.13.0" + version = "0.14.0" } } } diff --git a/examples/provider.tf b/examples/provider.tf index 7a3b3e0..35341ec 100644 --- a/examples/provider.tf +++ b/examples/provider.tf @@ -2,7 +2,7 @@ terraform { required_providers { gitea = { source = "terraform.local/lerentis/gitea" - version = "0.13.0" + version = "0.14.0" } } } diff --git a/examples/provider/provider.tf b/examples/provider/provider.tf index fd96593..9a8409a 100644 --- a/examples/provider/provider.tf +++ b/examples/provider/provider.tf @@ -2,7 +2,7 @@ terraform { required_providers { gitea = { source = "Lerentis/gitea" - version = "0.13.0" + version = "0.14.0" } } } diff --git a/gitea/resource_gitea_repository.go b/gitea/resource_gitea_repository.go index 01f0212..065112e 100644 --- a/gitea/resource_gitea_repository.go +++ b/gitea/resource_gitea_repository.go @@ -131,14 +131,14 @@ func resourceRepoCreate(d *schema.ResourceData, meta interface{}) (err error) { orgRepo = true } - if (d.Get(repoMirror)).(bool) { + var cloneAddr string + if d.Get(migrationCloneAddresse).(string) != "" { + cloneAddr = d.Get(migrationCloneAddresse).(string) + } else { + cloneAddr = d.Get(migrationCloneAddress).(string) + } - var cloneAddr string - if d.Get(migrationCloneAddresse).(string) != "" { - cloneAddr = d.Get(migrationCloneAddresse).(string) - } else { - cloneAddr = d.Get(migrationCloneAddress).(string) - } + if cloneAddr != "" { opts := gitea.MigrateRepoOption{ RepoName: d.Get(repoName).(string), From 98867f2830a1946d71c16da91f24b282b0670190 Mon Sep 17 00:00:00 2001 From: ultimania Date: Wed, 31 May 2023 10:27:59 +0900 Subject: [PATCH 2/2] add example for origin migration --- docs/resources/repository.md | 10 ++++++++++ examples/resources/gitea_repository/resource.tf | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/docs/resources/repository.md b/docs/resources/repository.md index 559c018..f7c9d0a 100644 --- a/docs/resources/repository.md +++ b/docs/resources/repository.md @@ -41,6 +41,16 @@ resource "gitea_repository" "mirror" { migration_service = "gitea" migration_service_auth_token = var.gitea_mirror_token } + +resource "gitea_repository" "clone" { + username = "lerentis" + name = "terraform-provider-gitea-clone" + description = "Clone of Terraform Provider" + mirror = false + migration_clone_address = "https://git.uploadfilter24.eu/lerentis/terraform-provider-gitea.git" + migration_service = "gitea" + migration_service_auth_token = var.gitea_clone_token +} ``` diff --git a/examples/resources/gitea_repository/resource.tf b/examples/resources/gitea_repository/resource.tf index c6753ce..f18838b 100644 --- a/examples/resources/gitea_repository/resource.tf +++ b/examples/resources/gitea_repository/resource.tf @@ -16,3 +16,13 @@ resource "gitea_repository" "mirror" { migration_service = "gitea" migration_service_auth_token = var.gitea_mirror_token } + +resource "gitea_repository" "clone" { + username = "lerentis" + name = "terraform-provider-gitea-clone" + description = "Clone of Terraform Provider" + mirror = false + migration_clone_address = "https://git.uploadfilter24.eu/lerentis/terraform-provider-gitea.git" + migration_service = "gitea" + migration_service_auth_token = var.gitea_clone_token +}