diff --git a/data_source_quantum_list_files.go b/data_source_quantum_list_files.go index 6bf64dc..ea671cd 100644 --- a/data_source_quantum_list_files.go +++ b/data_source_quantum_list_files.go @@ -1,6 +1,7 @@ package main import ( + "fmt" "os" "path/filepath" "strings" @@ -10,33 +11,34 @@ import ( func dataSourceQuantumListFiles() *schema.Resource { return &schema.Resource{ - Read: dataSourceQuantumListFilesRead, + DeprecationMessage: "Please use `fileset` instead: https://www.terraform.io/docs/configuration/functions/fileset.html", + Read: dataSourceQuantumListFilesRead, Schema: map[string]*schema.Schema{ - "folders": &schema.Schema{ + "folders": { Type: schema.TypeList, Optional: true, Elem: &schema.Schema{ Type: schema.TypeString, }, }, - "patterns": &schema.Schema{ + "patterns": { Type: schema.TypeList, Optional: true, Elem: &schema.Schema{ Type: schema.TypeString, }, }, - "include_folder": &schema.Schema{ + "include_folder": { Type: schema.TypeBool, Optional: true, Default: true, }, - "recursive": &schema.Schema{ + "recursive": { Type: schema.TypeBool, Optional: true, }, - "files": &schema.Schema{ + "files": { Type: schema.TypeList, Computed: true, Elem: &schema.Schema{ @@ -63,7 +65,15 @@ func dataSourceQuantumListFilesRead(d *schema.ResourceData, m interface{}) error var result []string for _, folder := range folders { - err := filepath.Walk(folder, func(path string, info os.FileInfo, err error) error { + folderInfo, err := os.Stat(folder) + if os.IsNotExist(err) { + return fmt.Errorf("%s does not exist", folder) + } + if !folderInfo.IsDir() { + return fmt.Errorf("%s is not a dir", folder) + } + + err = filepath.Walk(folder, func(path string, info os.FileInfo, err error) error { for _, pattern := range patterns { matched, err := filepath.Match(pattern, filepath.Base(path)) if err != nil { diff --git a/data_source_quantum_query_json.go b/data_source_quantum_query_json.go index a9e3a24..eb66bc8 100644 --- a/data_source_quantum_query_json.go +++ b/data_source_quantum_query_json.go @@ -10,27 +10,28 @@ import ( func dataSourceQuantumQueryJSON() *schema.Resource { return &schema.Resource{ - Read: dataSourceQuantumQueryJSONRead, + DeprecationMessage: "Terraform 0.12 supports nested maps. Ex: jsondecode(var.my_variable).attribute1.attribute2", + Read: dataSourceQuantumQueryJSONRead, Schema: map[string]*schema.Schema{ - "json": &schema.Schema{ + "json": { Type: schema.TypeString, Required: true, }, - "query": &schema.Schema{ + "query": { Type: schema.TypeString, Required: true, }, - "result_list": &schema.Schema{ + "result_list": { Computed: true, Elem: &schema.Schema{Type: schema.TypeString}, Type: schema.TypeList, }, - "result_map": &schema.Schema{ + "result_map": { Computed: true, Type: schema.TypeMap, }, - "result": &schema.Schema{ + "result": { Type: schema.TypeString, Computed: true, },