Add descriptions for AWS inputs

This commit is contained in:
Mitchell Hashimoto 2014-09-29 13:30:28 -07:00
parent 901c1448b4
commit 99044a1f14
3 changed files with 27 additions and 2 deletions

View File

@ -22,18 +22,21 @@ func Provider() *schema.Provider {
Type: schema.TypeString,
Required: true,
DefaultFunc: envDefaultFunc("AWS_REGION"),
Description: descriptions["region"],
},
"access_key": &schema.Schema{
Type: schema.TypeString,
Required: true,
DefaultFunc: envDefaultFunc("AWS_ACCESS_KEY"),
Description: descriptions["access_key"],
},
"secret_key": &schema.Schema{
Type: schema.TypeString,
Required: true,
DefaultFunc: envDefaultFunc("AWS_SECRET_KEY"),
Description: descriptions["secret_key"],
},
},
@ -55,3 +58,18 @@ func envDefaultFunc(k string) schema.SchemaDefaultFunc {
return nil, nil
}
}
var descriptions map[string]string
func init() {
descriptions = map[string]string{
"region": "The region where AWS operations will take place. Examples\n" +
"are us-east-1, us-west-2, etc.",
"access_key": "The access key for API operations. You can retrieve this\n" +
"from the 'Security & Credentials' section of the AWS console.",
"secret_key": "The secret key for API operations. You can retrieve this\n" +
"from the 'Security & Credentials' section of the AWS console.",
}
}

View File

@ -100,6 +100,7 @@ func (i *UIInput) Input(opts *terraform.InputOpts) (string, error) {
select {
case line := <-result:
fmt.Fprint(w, "\n")
return line, nil
case <-sigCh:
// Print a newline so that any further output starts properly

View File

@ -74,6 +74,11 @@ type Schema struct {
Default interface{}
DefaultFunc SchemaDefaultFunc
// Description is used as the description for docs or asking for user
// input. It should be relatively short (a few sentences max) and should
// be formatted to fit a CLI.
Description string
// The fields below relate to diffs.
//
// If Computed is true, then the result of this value is computed
@ -615,8 +620,9 @@ func (m schemaMap) inputString(
k string,
schema *Schema) (interface{}, error) {
result, err := input.Input(&terraform.InputOpts{
Id: k,
Query: k,
Id: k,
Query: k,
Description: schema.Description,
})
return result, err