Compare commits

..

No commits in common. "8e2fc7264bb8a913a9cd259835d95e438ad9708a" and "cf2fc0f54f8f21b7c7136be9d53743f8ba374957" have entirely different histories.

8 changed files with 16 additions and 55 deletions

View File

@ -15,24 +15,13 @@ steps:
- push
- pull_request
- tag
- name: build-dev
image: golang:1.18.3-alpine3.16
commands:
- "apk add --update --no-cache make"
- "make build"
when:
event:
- push
resources:
limits:
cpu: 1000
memory: 1024MiB
- name: build
image: goreleaser/goreleaser
commands:
- goreleaser build --snapshot
when:
event:
- push
- pull_request
resources:
limits:

View File

@ -3,7 +3,7 @@ GOFMT_FILES?=$$(find . -name '*.go' |grep -v vendor)
GOFMT ?= gofmt -s
VERSION = 0.7.2
VERSION = 0.7.1
test: fmt-check
go test -i $(TEST) || exit 1

View File

@ -17,7 +17,7 @@ terraform {
required_providers {
gitea = {
source = "Lerentis/gitea"
version = "0.7.2"
version = "0.7.1"
}
}
}

View File

@ -17,7 +17,7 @@ terraform {
required_providers {
gitea = {
source = "Lerentis/gitea"
version = "0.7.2"
version = "0.3.0"
}
}
}

View File

@ -19,7 +19,6 @@ resource "gitea_repository" "mirror" {
resource "gitea_org" "test_org" {
name = "test-org"
description = "test description"
}
resource "gitea_repository" "org_repo" {

View File

@ -2,7 +2,7 @@ terraform {
required_providers {
gitea = {
source = "terraform.local/lerentis/gitea"
version = "0.7.2"
version = "0.7.1"
}
}
}

View File

@ -2,7 +2,7 @@ terraform {
required_providers {
gitea = {
source = "Lerentis/gitea"
version = "0.7.2"
version = "0.3.0"
}
}
}

View File

@ -2,7 +2,6 @@ package gitea
import (
"fmt"
"strconv"
"code.gitea.io/sdk/gitea"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
@ -18,48 +17,22 @@ const (
RepoAdminChangeTeamAccess string = "repo_admin_change_team_access"
)
// might come in handy if we want to stick to numeric IDs
func searchOrgByClientId(c *gitea.Client, id int64) (res *gitea.Organization, err error) {
page := 1
for {
orgs, _, err := c.AdminListOrgs(gitea.AdminListOrgsOptions{
ListOptions: gitea.ListOptions{
Page: page,
PageSize: 50,
},
})
if err != nil {
return nil, err
}
if len(orgs) == 0 {
return nil, fmt.Errorf("Organisation with ID %d could not be found", id)
}
for _, org := range orgs {
if org.ID == id {
return org, nil
}
}
page += 1
}
}
func resourceOrgRead(d *schema.ResourceData, meta interface{}) (err error) {
client := meta.(*gitea.Client)
var org *gitea.Organization
var resp *gitea.Response
id, err := strconv.ParseInt(d.Id(), 10, 64)
org, err = searchOrgByClientId(client, id)
org, resp, err = client.GetOrg(d.Get(orgName).(string))
if err != nil {
if resp.StatusCode == 404 {
d.SetId("")
return nil
} else {
return err
}
}
err = setOrgResourceData(org, d)
@ -160,7 +133,7 @@ func resourceGiteaOrg() *schema.Resource {
Update: resourceOrgUpdate,
Delete: resourceOrgDelete,
Importer: &schema.ResourceImporter{
StateContext: schema.ImportStatePassthroughContext,
State: schema.ImportStatePassthrough,
},
Schema: map[string]*schema.Schema{
"name": {