github.com/mohanarpit/terraform@v0.6.16-0.20160909104007-291f29853544/builtin/providers/rundeck/provider.go (about)

     1  package rundeck
     2  
     3  import (
     4  	"github.com/hashicorp/terraform/helper/schema"
     5  	"github.com/hashicorp/terraform/terraform"
     6  
     7  	"github.com/apparentlymart/go-rundeck-api/rundeck"
     8  )
     9  
    10  func Provider() terraform.ResourceProvider {
    11  	return &schema.Provider{
    12  		Schema: map[string]*schema.Schema{
    13  			"url": &schema.Schema{
    14  				Type:        schema.TypeString,
    15  				Required:    true,
    16  				DefaultFunc: schema.EnvDefaultFunc("RUNDECK_URL", nil),
    17  				Description: "URL of the root of the target Rundeck server.",
    18  			},
    19  			"auth_token": &schema.Schema{
    20  				Type:        schema.TypeString,
    21  				Required:    true,
    22  				DefaultFunc: schema.EnvDefaultFunc("RUNDECK_AUTH_TOKEN", nil),
    23  				Description: "Auth token to use with the Rundeck API.",
    24  			},
    25  			"allow_unverified_ssl": &schema.Schema{
    26  				Type:        schema.TypeBool,
    27  				Optional:    true,
    28  				Description: "If set, the Rundeck client will permit unverifiable SSL certificates.",
    29  			},
    30  		},
    31  
    32  		ResourcesMap: map[string]*schema.Resource{
    33  			"rundeck_project":     resourceRundeckProject(),
    34  			"rundeck_job":         resourceRundeckJob(),
    35  			"rundeck_private_key": resourceRundeckPrivateKey(),
    36  			"rundeck_public_key":  resourceRundeckPublicKey(),
    37  		},
    38  
    39  		ConfigureFunc: providerConfigure,
    40  	}
    41  }
    42  
    43  func providerConfigure(d *schema.ResourceData) (interface{}, error) {
    44  	config := &rundeck.ClientConfig{
    45  		BaseURL:            d.Get("url").(string),
    46  		AuthToken:          d.Get("auth_token").(string),
    47  		AllowUnverifiedSSL: d.Get("allow_unverified_ssl").(bool),
    48  	}
    49  
    50  	return rundeck.NewClient(config)
    51  }