Compare commits
3 Commits
1162650a73
...
v0.12.3
Author | SHA1 | Date | |
---|---|---|---|
0a85957c50 | |||
f87515a453 | |||
0e8aa2bf9b |
10
Makefile
10
Makefile
@ -1,9 +1,11 @@
|
||||
TEST?=./gitea
|
||||
GOFMT_FILES?=$$(find . -name '*.go' |grep -v vendor)
|
||||
ARCH?=$$(uname -m)
|
||||
KERNEL?=$$(uname -s | tr '[:upper:]' '[:lower:]')
|
||||
|
||||
GOFMT ?= gofmt -s
|
||||
|
||||
VERSION = 0.12.2
|
||||
VERSION = 0.12.3
|
||||
|
||||
test: fmt-check
|
||||
go test -i $(TEST) || exit 1
|
||||
@ -34,8 +36,8 @@ build:
|
||||
go build -ldflags="-X 'main.Version=${VERSION}'" -o terraform-provider-gitea_${VERSION}
|
||||
install: build
|
||||
@echo installing to
|
||||
@echo ~/.terraform.d/plugins/terraform.local/lerentis/gitea/${VERSION}/linux_amd64/terraform-provider-gitea_${VERSION}
|
||||
@mkdir -p ~/.terraform.d/plugins/terraform.local/lerentis/gitea/${VERSION}/linux_amd64
|
||||
@mv terraform-provider-gitea_${VERSION} ~/.terraform.d/plugins/terraform.local/lerentis/gitea/${VERSION}/linux_amd64/terraform-provider-gitea_${VERSION}
|
||||
@echo ~/.terraform.d/plugins/terraform.local/lerentis/gitea/${VERSION}/${KERNEL}_${ARCH}/terraform-provider-gitea_${VERSION}
|
||||
@mkdir -p ~/.terraform.d/plugins/terraform.local/lerentis/gitea/${VERSION}/${KERNEL}_${ARCH}
|
||||
@mv terraform-provider-gitea_${VERSION} ~/.terraform.d/plugins/terraform.local/lerentis/gitea/${VERSION}/${KERNEL}_${ARCH}/terraform-provider-gitea_${VERSION}
|
||||
doc:
|
||||
tfplugindocs
|
||||
|
@ -17,7 +17,7 @@ terraform {
|
||||
required_providers {
|
||||
gitea = {
|
||||
source = "Lerentis/gitea"
|
||||
version = "0.12.2"
|
||||
version = "0.12.3"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ terraform {
|
||||
required_providers {
|
||||
gitea = {
|
||||
source = "Lerentis/gitea"
|
||||
version = "0.12.2"
|
||||
version = "0.12.3"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ description: |-
|
||||
Per default this repository will be initializiled with the provided configuration (gitignore, License etc.).
|
||||
If the username property is set to a organisation name, the provider will try to look if this organisation exists and create the repository under the organisation scope.
|
||||
Repository migrations have some properties that are not available to regular repositories. These are all prefixed with migration_.
|
||||
Codeberg.org does currently not allow mirrors to be created. See FAQ Section of CodeBerg for more information: https://docs.codeberg.org/getting-started/faq/#why-am-i-not-allowed-to-set-up-an-automatic-mirror
|
||||
---
|
||||
|
||||
# gitea_repository (Resource)
|
||||
@ -17,6 +18,7 @@ Per default this repository will be initializiled with the provided configuratio
|
||||
If the `username` property is set to a organisation name, the provider will try to look if this organisation exists and create the repository under the organisation scope.
|
||||
|
||||
Repository migrations have some properties that are not available to regular repositories. These are all prefixed with `migration_`.
|
||||
Codeberg.org does currently not allow mirrors to be created. See FAQ Section of CodeBerg for more information: https://docs.codeberg.org/getting-started/faq/#why-am-i-not-allowed-to-set-up-an-automatic-mirror
|
||||
|
||||
## Example Usage
|
||||
|
||||
|
@ -2,7 +2,7 @@ terraform {
|
||||
required_providers {
|
||||
gitea = {
|
||||
source = "terraform.local/lerentis/gitea"
|
||||
version = "0.12.2"
|
||||
version = "0.12.3"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ terraform {
|
||||
required_providers {
|
||||
gitea = {
|
||||
source = "Lerentis/gitea"
|
||||
version = "0.12.2"
|
||||
version = "0.12.3"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,14 @@
|
||||
package gitea
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
"github.com/hashicorp/terraform-plugin-log/tflog"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
@ -108,14 +111,20 @@ func resourceRepoCreate(d *schema.ResourceData, meta interface{}) (err error) {
|
||||
|
||||
var repo *gitea.Repository
|
||||
var resp *gitea.Response
|
||||
var orgRepo bool
|
||||
var orgRepo, hasAdmin bool
|
||||
|
||||
_, resp, err = client.GetOrg(d.Get(repoOwner).(string))
|
||||
|
||||
if resp.StatusCode == 404 {
|
||||
_, err := searchUserByName(client, d.Get(repoOwner).(string))
|
||||
if err != nil {
|
||||
return errors.New(fmt.Sprintf("Creation of repository cound not proceed as owner %s is not present in gitea", d.Get(repoOwner).(string)))
|
||||
if strings.Contains(err.Error(), "could not be found") {
|
||||
return errors.New(fmt.Sprintf("Creation of repository cound not proceed as owner %s is not present in gitea", d.Get(repoOwner).(string)))
|
||||
}
|
||||
tflog.Warn(context.Background(), "Error query for users. Assuming missing permissions and proceding with user permissions")
|
||||
hasAdmin = false
|
||||
} else {
|
||||
hasAdmin = true
|
||||
}
|
||||
orgRepo = false
|
||||
} else {
|
||||
@ -180,7 +189,11 @@ func resourceRepoCreate(d *schema.ResourceData, meta interface{}) (err error) {
|
||||
if orgRepo {
|
||||
repo, _, err = client.CreateOrgRepo(d.Get(repoOwner).(string), opts)
|
||||
} else {
|
||||
repo, _, err = client.AdminCreateRepo(d.Get(repoOwner).(string), opts)
|
||||
if hasAdmin {
|
||||
repo, _, err = client.AdminCreateRepo(d.Get(repoOwner).(string), opts)
|
||||
} else {
|
||||
repo, _, err = client.CreateRepo(opts)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -580,6 +593,8 @@ func resourceGiteaRepository() *schema.Resource {
|
||||
"Per default this repository will be initializiled with the provided configuration (gitignore, License etc.).\n" +
|
||||
"If the `username` property is set to a organisation name, the provider will try to look if this organisation exists " +
|
||||
"and create the repository under the organisation scope.\n\n" +
|
||||
"Repository migrations have some properties that are not available to regular repositories. These are all prefixed with `migration_`.",
|
||||
"Repository migrations have some properties that are not available to regular repositories. These are all prefixed with `migration_`.\n" +
|
||||
"Codeberg.org does currently not allow mirrors to be created. See FAQ Section of CodeBerg for more information: " +
|
||||
"https://docs.codeberg.org/getting-started/faq/#why-am-i-not-allowed-to-set-up-an-automatic-mirror",
|
||||
}
|
||||
}
|
||||
|
4
go.mod
4
go.mod
@ -5,7 +5,8 @@ go 1.18
|
||||
require (
|
||||
code.gitea.io/sdk/gitea v0.15.1
|
||||
github.com/hashicorp/terraform-plugin-docs v0.14.1
|
||||
github.com/hashicorp/terraform-plugin-sdk/v2 v2.26.0
|
||||
github.com/hashicorp/terraform-plugin-log v0.8.0
|
||||
github.com/hashicorp/terraform-plugin-sdk/v2 v2.26.1
|
||||
)
|
||||
|
||||
require (
|
||||
@ -35,7 +36,6 @@ require (
|
||||
github.com/hashicorp/terraform-exec v0.18.1 // indirect
|
||||
github.com/hashicorp/terraform-json v0.16.0 // indirect
|
||||
github.com/hashicorp/terraform-plugin-go v0.14.3 // indirect
|
||||
github.com/hashicorp/terraform-plugin-log v0.8.0 // indirect
|
||||
github.com/hashicorp/terraform-registry-address v0.1.0 // indirect
|
||||
github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 // indirect
|
||||
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d // indirect
|
||||
|
4
go.sum
4
go.sum
@ -124,8 +124,8 @@ github.com/hashicorp/terraform-plugin-go v0.14.3 h1:nlnJ1GXKdMwsC8g1Nh05tK2wsC3+
|
||||
github.com/hashicorp/terraform-plugin-go v0.14.3/go.mod h1:7ees7DMZ263q8wQ6E4RdIdR6nHHJtrdt4ogX5lPkX1A=
|
||||
github.com/hashicorp/terraform-plugin-log v0.8.0 h1:pX2VQ/TGKu+UU1rCay0OlzosNKe4Nz1pepLXj95oyy0=
|
||||
github.com/hashicorp/terraform-plugin-log v0.8.0/go.mod h1:1myFrhVsBLeylQzYYEV17VVjtG8oYPRFdaZs7xdW2xs=
|
||||
github.com/hashicorp/terraform-plugin-sdk/v2 v2.26.0 h1:We3H/dXP7Q0YH4YsBY6DAVj+Ur6PDFC+Yt1btGhTeMs=
|
||||
github.com/hashicorp/terraform-plugin-sdk/v2 v2.26.0/go.mod h1:xcOSYlRVdPLmDUoqPhO9fiO/YCN/l6MGYeTzGt5jgkQ=
|
||||
github.com/hashicorp/terraform-plugin-sdk/v2 v2.26.1 h1:G9WAfb8LHeCxu7Ae8nc1agZlQOSCUWsb610iAogBhCs=
|
||||
github.com/hashicorp/terraform-plugin-sdk/v2 v2.26.1/go.mod h1:xcOSYlRVdPLmDUoqPhO9fiO/YCN/l6MGYeTzGt5jgkQ=
|
||||
github.com/hashicorp/terraform-registry-address v0.1.0 h1:W6JkV9wbum+m516rCl5/NjKxCyTVaaUBbzYcMzBDO3U=
|
||||
github.com/hashicorp/terraform-registry-address v0.1.0/go.mod h1:EnyO2jYO6j29DTHbJcm00E5nQTFeTtyZH3H5ycydQ5A=
|
||||
github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 h1:HKLsbzeOsfXmKNpr3GiT18XAblV0BjCbzL8KQAMZGa0=
|
||||
|
18
vendor/github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource/aliases.go
generated
vendored
18
vendor/github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource/aliases.go
generated
vendored
@ -42,19 +42,19 @@ func PrefixedUniqueId(prefix string) string {
|
||||
|
||||
// Deprecated: Use helper/retry package instead. This is required for migrating acceptance
|
||||
// testing to terraform-plugin-testing.
|
||||
type NotFoundError retry.NotFoundError
|
||||
type NotFoundError = retry.NotFoundError
|
||||
|
||||
// UnexpectedStateError is returned when Refresh returns a state that's neither in Target nor Pending
|
||||
//
|
||||
// Deprecated: Use helper/retry package instead. This is required for migrating acceptance
|
||||
// testing to terraform-plugin-testing.
|
||||
type UnexpectedStateError retry.UnexpectedStateError
|
||||
type UnexpectedStateError = retry.UnexpectedStateError
|
||||
|
||||
// TimeoutError is returned when WaitForState times out
|
||||
//
|
||||
// Deprecated: Use helper/retry package instead. This is required for migrating acceptance
|
||||
// testing to terraform-plugin-testing.
|
||||
type TimeoutError retry.TimeoutError
|
||||
type TimeoutError = retry.TimeoutError
|
||||
|
||||
// StateRefreshFunc is a function type used for StateChangeConf that is
|
||||
// responsible for refreshing the item being watched for a state change.
|
||||
@ -69,19 +69,19 @@ type TimeoutError retry.TimeoutError
|
||||
//
|
||||
// Deprecated: Use helper/retry package instead. This is required for migrating acceptance
|
||||
// testing to terraform-plugin-testing.
|
||||
type StateRefreshFunc retry.StateRefreshFunc
|
||||
type StateRefreshFunc = retry.StateRefreshFunc
|
||||
|
||||
// StateChangeConf is the configuration struct used for `WaitForState`.
|
||||
//
|
||||
// Deprecated: Use helper/retry package instead. This is required for migrating acceptance
|
||||
// testing to terraform-plugin-testing.
|
||||
type StateChangeConf retry.StateChangeConf
|
||||
type StateChangeConf = retry.StateChangeConf
|
||||
|
||||
// RetryFunc is the function retried until it succeeds.
|
||||
//
|
||||
// Deprecated: Use helper/retry package instead. This is required for migrating acceptance
|
||||
// testing to terraform-plugin-testing.
|
||||
type RetryFunc retry.RetryFunc
|
||||
type RetryFunc = retry.RetryFunc
|
||||
|
||||
// RetryContext is a basic wrapper around StateChangeConf that will just retry
|
||||
// a function until it no longer returns an error.
|
||||
@ -92,7 +92,7 @@ type RetryFunc retry.RetryFunc
|
||||
// Deprecated: Use helper/retry package instead. This is required for migrating acceptance
|
||||
// testing to terraform-plugin-testing.
|
||||
func RetryContext(ctx context.Context, timeout time.Duration, f RetryFunc) error {
|
||||
return retry.RetryContext(ctx, timeout, retry.RetryFunc(f))
|
||||
return retry.RetryContext(ctx, timeout, f)
|
||||
}
|
||||
|
||||
// Retry is a basic wrapper around StateChangeConf that will just retry
|
||||
@ -101,7 +101,7 @@ func RetryContext(ctx context.Context, timeout time.Duration, f RetryFunc) error
|
||||
// Deprecated: Use helper/retry package instead. This is required for migrating acceptance
|
||||
// testing to terraform-plugin-testing.
|
||||
func Retry(timeout time.Duration, f RetryFunc) error {
|
||||
return retry.Retry(timeout, retry.RetryFunc(f))
|
||||
return retry.Retry(timeout, f)
|
||||
}
|
||||
|
||||
// RetryError is the required return type of RetryFunc. It forces client code
|
||||
@ -109,7 +109,7 @@ func Retry(timeout time.Duration, f RetryFunc) error {
|
||||
//
|
||||
// Deprecated: Use helper/retry package instead. This is required for migrating acceptance
|
||||
// testing to terraform-plugin-testing.
|
||||
type RetryError retry.RetryError
|
||||
type RetryError = retry.RetryError
|
||||
|
||||
// RetryableError is a helper to create a RetryError that's retryable from a
|
||||
// given error. To prevent logic errors, will return an error when passed a
|
||||
|
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
@ -141,7 +141,7 @@ github.com/hashicorp/terraform-plugin-log/internal/hclogutils
|
||||
github.com/hashicorp/terraform-plugin-log/internal/logging
|
||||
github.com/hashicorp/terraform-plugin-log/tflog
|
||||
github.com/hashicorp/terraform-plugin-log/tfsdklog
|
||||
# github.com/hashicorp/terraform-plugin-sdk/v2 v2.26.0
|
||||
# github.com/hashicorp/terraform-plugin-sdk/v2 v2.26.1
|
||||
## explicit; go 1.19
|
||||
github.com/hashicorp/terraform-plugin-sdk/v2/diag
|
||||
github.com/hashicorp/terraform-plugin-sdk/v2/helper/id
|
||||
|
Reference in New Issue
Block a user