Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
3dd609864b
|
|||
13d3ed85ad
|
|||
b23c36a25f
|
|||
87d8cfd2e5 | |||
85b869d28b |
2
Makefile
2
Makefile
@ -3,7 +3,7 @@ GOFMT_FILES?=$$(find . -name '*.go' |grep -v vendor)
|
|||||||
|
|
||||||
GOFMT ?= gofmt -s
|
GOFMT ?= gofmt -s
|
||||||
|
|
||||||
VERSION = 0.10.0
|
VERSION = 0.11.1
|
||||||
|
|
||||||
test: fmt-check
|
test: fmt-check
|
||||||
go test -i $(TEST) || exit 1
|
go test -i $(TEST) || exit 1
|
||||||
|
@ -17,7 +17,7 @@ terraform {
|
|||||||
required_providers {
|
required_providers {
|
||||||
gitea = {
|
gitea = {
|
||||||
source = "Lerentis/gitea"
|
source = "Lerentis/gitea"
|
||||||
version = "0.10.0"
|
version = "0.11.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ terraform {
|
|||||||
required_providers {
|
required_providers {
|
||||||
gitea = {
|
gitea = {
|
||||||
source = "Lerentis/gitea"
|
source = "Lerentis/gitea"
|
||||||
version = "0.10.0"
|
version = "0.11.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,10 @@ Need to exist in the gitea instance
|
|||||||
### Read-Only
|
### Read-Only
|
||||||
|
|
||||||
- `created` (String)
|
- `created` (String)
|
||||||
|
- `clone_url` (String)
|
||||||
|
- `html_url` (String)
|
||||||
- `id` (String) The ID of this resource.
|
- `id` (String) The ID of this resource.
|
||||||
|
- `ssh_url` (String)
|
||||||
- `permission_admin` (Boolean)
|
- `permission_admin` (Boolean)
|
||||||
- `permission_pull` (Boolean)
|
- `permission_pull` (Boolean)
|
||||||
- `permission_push` (Boolean)
|
- `permission_push` (Boolean)
|
||||||
|
@ -2,7 +2,7 @@ terraform {
|
|||||||
required_providers {
|
required_providers {
|
||||||
gitea = {
|
gitea = {
|
||||||
source = "terraform.local/lerentis/gitea"
|
source = "terraform.local/lerentis/gitea"
|
||||||
version = "0.10.0"
|
version = "0.11.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ terraform {
|
|||||||
required_providers {
|
required_providers {
|
||||||
gitea = {
|
gitea = {
|
||||||
source = "Lerentis/gitea"
|
source = "Lerentis/gitea"
|
||||||
version = "0.10.0"
|
version = "0.11.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"time"
|
||||||
|
|
||||||
"code.gitea.io/sdk/gitea"
|
"code.gitea.io/sdk/gitea"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/logging"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/logging"
|
||||||
@ -28,8 +29,7 @@ func (c *Config) Client() (interface{}, error) {
|
|||||||
return nil, fmt.Errorf("either a token or a username needs to be used")
|
return nil, fmt.Errorf("either a token or a username needs to be used")
|
||||||
}
|
}
|
||||||
// Configure TLS/SSL
|
// Configure TLS/SSL
|
||||||
tlsConfig := &tls.Config{}
|
var tlsConfig tls.Config
|
||||||
|
|
||||||
// If a CACertFile has been specified, use that for cert validation
|
// If a CACertFile has been specified, use that for cert validation
|
||||||
if c.CACertFile != "" {
|
if c.CACertFile != "" {
|
||||||
caCert, err := ioutil.ReadFile(c.CACertFile)
|
caCert, err := ioutil.ReadFile(c.CACertFile)
|
||||||
@ -43,13 +43,12 @@ func (c *Config) Client() (interface{}, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If configured as insecure, turn off SSL verification
|
// If configured as insecure, turn off SSL verification
|
||||||
if c.Insecure {
|
tlsConfig.InsecureSkipVerify = c.Insecure
|
||||||
tlsConfig.InsecureSkipVerify = true
|
|
||||||
}
|
|
||||||
|
|
||||||
t := http.DefaultTransport.(*http.Transport).Clone()
|
t := http.DefaultTransport.(*http.Transport).Clone()
|
||||||
t.TLSClientConfig = tlsConfig
|
t.TLSClientConfig = &tlsConfig
|
||||||
t.MaxIdleConnsPerHost = 100
|
t.MaxIdleConnsPerHost = 100
|
||||||
|
t.TLSHandshakeTimeout = 10 * time.Second
|
||||||
|
|
||||||
httpClient := &http.Client{
|
httpClient := &http.Client{
|
||||||
Transport: logging.NewTransport("Gitea", t),
|
Transport: logging.NewTransport("Gitea", t),
|
||||||
@ -60,16 +59,23 @@ func (c *Config) Client() (interface{}, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var client *gitea.Client
|
var client *gitea.Client
|
||||||
|
var err error
|
||||||
if c.Token != "" {
|
if c.Token != "" {
|
||||||
client, _ = gitea.NewClient(c.BaseURL, gitea.SetToken(c.Token), gitea.SetHTTPClient(httpClient))
|
client, err = gitea.NewClient(c.BaseURL, gitea.SetToken(c.Token), gitea.SetHTTPClient(httpClient))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.Username != "" {
|
if c.Username != "" {
|
||||||
client, _ = gitea.NewClient(c.BaseURL, gitea.SetBasicAuth(c.Username, c.Password), gitea.SetHTTPClient(httpClient))
|
client, err = gitea.NewClient(c.BaseURL, gitea.SetBasicAuth(c.Username, c.Password), gitea.SetHTTPClient(httpClient))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test the credentials by checking we can get information about the authenticated user.
|
// Test the credentials by checking we can get information about the authenticated user.
|
||||||
_, _, err := client.GetMyUserInfo()
|
_, _, err = client.GetMyUserInfo()
|
||||||
|
|
||||||
return client, err
|
return client, err
|
||||||
}
|
}
|
||||||
|
@ -78,16 +78,6 @@ func resourceRepoCreate(d *schema.ResourceData, meta interface{}) (err error) {
|
|||||||
client := meta.(*gitea.Client)
|
client := meta.(*gitea.Client)
|
||||||
|
|
||||||
var repo *gitea.Repository
|
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) {
|
if (d.Get(repoMirror)).(bool) {
|
||||||
|
|
||||||
@ -144,15 +134,11 @@ func resourceRepoCreate(d *schema.ResourceData, meta interface{}) (err error) {
|
|||||||
TrustModel: "default",
|
TrustModel: "default",
|
||||||
}
|
}
|
||||||
|
|
||||||
if orgRepo {
|
|
||||||
repo, _, err = client.CreateOrgRepo(d.Get(repoOwner).(string), opts)
|
repo, _, err = client.CreateOrgRepo(d.Get(repoOwner).(string), opts)
|
||||||
} else {
|
|
||||||
repo, _, err = client.CreateRepo(opts)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = setRepoResourceData(repo, d)
|
err = setRepoResourceData(repo, d)
|
||||||
@ -530,6 +516,18 @@ func resourceGiteaRepository() *schema.Resource {
|
|||||||
Optional: true,
|
Optional: true,
|
||||||
Default: "",
|
Default: "",
|
||||||
},
|
},
|
||||||
|
"clone_url": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"html_url": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
"ssh_url": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Description: "`gitea_repository` manages a gitea repository.\n\n" +
|
Description: "`gitea_repository` manages a gitea repository.\n\n" +
|
||||||
"Per default this repository will be initializiled with the provided configuration (gitignore, License etc.).\n" +
|
"Per default this repository will be initializiled with the provided configuration (gitignore, License etc.).\n" +
|
||||||
|
Reference in New Issue
Block a user