Skip to content

Commit

Permalink
Make optional parameters actually optional with a default value
Browse files Browse the repository at this point in the history
  • Loading branch information
Tamás Michelberger committed Jul 24, 2017
1 parent 1fd58e9 commit 70580cb
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,18 @@ func provider() terraform.ResourceProvider {
}, nil),
Description: "The region where AWS operations will take place. Examples\n" +
"are us-east-1, us-west-2, etc.",
InputDefault: "us-east-1",
},
"table": {
Type: schema.TypeString,
Required: true,
Optional: true,
Description: "The DynamoDB table where the secrets are stored.",
DefaultFunc: func() (interface{}, error) {
return "credential-store", nil
},
Default: "credential-store",
},
"profile": {
Type: schema.TypeString,
Required: true,
DefaultFunc: func() (interface{}, error) {
return defaultAWSProfile, nil
},
Description: "The profile that should be used to connect to AWS",
InputDefault: "default",
Type: schema.TypeString,
Optional: true,
Default: defaultAWSProfile,
Description: "The profile that should be used to connect to AWS",
},
},
ConfigureFunc: providerConfig,
Expand All @@ -61,7 +55,7 @@ func providerConfig(d *schema.ResourceData) (interface{}, error) {
var sess *session.Session
var err error
if profile != defaultAWSProfile {
log.Printf("[DEBUG] Creating a session for profile: %s", profile)
log.Printf("[DEBUG] creating a session for profile: %s", profile)
sess, err = session.NewSessionWithOptions(session.Options{
Config: aws.Config{Region: aws.String(region)},
Profile: profile,
Expand All @@ -74,6 +68,6 @@ func providerConfig(d *schema.ResourceData) (interface{}, error) {
return nil, err
}

log.Printf("[DEBUG] Configured credstash for table %s", table)
log.Printf("[DEBUG] configured credstash for table %s", table)
return credstash.New(table, sess), nil
}

0 comments on commit 70580cb

Please sign in to comment.