mirror of
https://github.com/ysoftdevs/terraform-provider-bitbucketserver.git
synced 2026-04-18 14:59:39 +02:00
Initial Commit
This commit is contained in:
52
bitbucket/provider.go
Normal file
52
bitbucket/provider.go
Normal file
@@ -0,0 +1,52 @@
|
||||
package bitbucket
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
||||
func Provider() terraform.ResourceProvider {
|
||||
return &schema.Provider{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"server": {
|
||||
Required: true,
|
||||
Type: schema.TypeString,
|
||||
DefaultFunc: schema.EnvDefaultFunc("BITBUCKET_SERVER", nil),
|
||||
},
|
||||
"username": {
|
||||
Required: true,
|
||||
Type: schema.TypeString,
|
||||
DefaultFunc: schema.EnvDefaultFunc("BITBUCKET_USERNAME", nil),
|
||||
},
|
||||
"password": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
DefaultFunc: schema.EnvDefaultFunc("BITBUCKET_PASSWORD", nil),
|
||||
},
|
||||
},
|
||||
ConfigureFunc: providerConfigure,
|
||||
ResourcesMap: map[string]*schema.Resource{
|
||||
"bitbucketserver_repository": resourceRepository(),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func providerConfigure(d *schema.ResourceData) (interface{}, error) {
|
||||
|
||||
serverSanitized := d.Get("server").(string)
|
||||
if strings.HasSuffix(serverSanitized, "/") {
|
||||
serverSanitized = serverSanitized[0 : len(serverSanitized)-1]
|
||||
}
|
||||
|
||||
client := &BitbucketClient{
|
||||
Server: serverSanitized,
|
||||
Username: d.Get("username").(string),
|
||||
Password: d.Get("password").(string),
|
||||
HTTPClient: &http.Client{},
|
||||
}
|
||||
|
||||
return client, nil
|
||||
}
|
||||
Reference in New Issue
Block a user