diff --git a/builtin/providers/consul/attr_reader.go b/builtin/providers/consul/attr_reader.go deleted file mode 100644 index fa79a69be..000000000 --- a/builtin/providers/consul/attr_reader.go +++ /dev/null @@ -1,17 +0,0 @@ -package consul - -import "time" - -type attrReader interface { - GetBool(schemaAttr) bool - GetBoolOK(schemaAttr) (b, ok bool) - GetDurationOK(schemaAttr) (time.Duration, bool) - GetFloat64OK(schemaAttr) (float64, bool) - GetIntOK(schemaAttr) (int, bool) - GetIntPtr(schemaAttr) *int - GetString(schemaAttr) string - GetStringOK(schemaAttr) (string, bool) - GetStringPtr(schemaAttr) *string - GetStringSlice(attrName schemaAttr) []string - BackingType() string -} diff --git a/builtin/providers/consul/attr_reader_config.go b/builtin/providers/consul/attr_reader_config.go deleted file mode 100644 index 66e03d9cd..000000000 --- a/builtin/providers/consul/attr_reader_config.go +++ /dev/null @@ -1,111 +0,0 @@ -package consul - -import ( - "time" - - "github.com/hashicorp/terraform/helper/schema" -) - -type configReader struct { - d *schema.ResourceData -} - -func newConfigReader(d *schema.ResourceData) *configReader { - return &configReader{ - d: d, - } -} - -func (r *configReader) BackingType() string { - return "config" -} - -func (r *configReader) GetBool(attrName schemaAttr) bool { - if v, ok := r.d.GetOk(string(attrName)); ok { - return v.(bool) - } - - return false -} - -func (r *configReader) GetBoolOK(attrName schemaAttr) (b, ok bool) { - if v, ok := r.d.GetOk(string(attrName)); ok { - return v.(bool), true - } - - return false, false -} - -func (r *configReader) GetDurationOK(attrName schemaAttr) (time.Duration, bool) { - if v, ok := r.d.GetOk(string(attrName)); ok { - d, err := time.ParseDuration(v.(string)) - if err != nil { - return time.Duration(0), false - } - return d, true - } - - return time.Duration(0), false -} - -func (r *configReader) GetFloat64OK(attrName schemaAttr) (float64, bool) { - if v, ok := r.d.GetOk(string(attrName)); ok { - return v.(float64), true - } - - return 0.0, false -} - -func (r *configReader) GetIntOK(attrName schemaAttr) (int, bool) { - if v, ok := r.d.GetOk(string(attrName)); ok { - return v.(int), true - } - - return 0, false -} - -func (r *configReader) GetIntPtr(attrName schemaAttr) *int { - if v, ok := r.d.GetOk(string(attrName)); ok { - i := v.(int) - return &i - } - - return nil -} - -func (r *configReader) GetString(attrName schemaAttr) string { - if v, ok := r.d.GetOk(string(attrName)); ok { - return v.(string) - } - - return "" -} - -func (r *configReader) GetStringOK(attrName schemaAttr) (string, bool) { - if v, ok := r.d.GetOk(string(attrName)); ok { - return v.(string), true - } - - return "", false -} - -func (r *configReader) GetStringPtr(attrName schemaAttr) *string { - if v, ok := r.d.GetOk(string(attrName)); ok { - switch v.(type) { - case string: - s := v.(string) - return &s - case *string: - return v.(*string) - } - } - - return nil -} - -func (r *configReader) GetStringSlice(attrName schemaAttr) []string { - if listRaw, ok := r.d.GetOk(string(attrName)); ok { - return listRaw.([]string) - } - return nil -} diff --git a/builtin/providers/consul/attr_writer.go b/builtin/providers/consul/attr_writer.go deleted file mode 100644 index c1785f6f1..000000000 --- a/builtin/providers/consul/attr_writer.go +++ /dev/null @@ -1,14 +0,0 @@ -package consul - -import "github.com/hashicorp/terraform/helper/schema" - -type attrWriter interface { - BackingType() string - - SetBool(schemaAttr, bool) error - SetFloat64(schemaAttr, float64) error - SetList(schemaAttr, []interface{}) error - SetMap(schemaAttr, map[string]interface{}) error - SetSet(schemaAttr, *schema.Set) error - SetString(schemaAttr, string) error -} diff --git a/builtin/providers/consul/attr_writer_map.go b/builtin/providers/consul/attr_writer_map.go deleted file mode 100644 index 071ff52a0..000000000 --- a/builtin/providers/consul/attr_writer_map.go +++ /dev/null @@ -1,70 +0,0 @@ -package consul - -import ( - "fmt" - "strconv" - - "github.com/hashicorp/terraform/helper/schema" -) - -type attrWriterMap struct { - m map[string]interface{} -} - -func newMapWriter(m map[string]interface{}) *attrWriterMap { - return &attrWriterMap{ - m: m, - } -} - -func (w *attrWriterMap) BackingType() string { - return "map" -} - -func (w *attrWriterMap) Set(name schemaAttr, v interface{}) error { - switch u := v.(type) { - case string: - return w.SetString(name, u) - case float64: - return w.SetFloat64(name, u) - case bool: - return w.SetBool(name, u) - case nil: - return w.SetString(name, "") - default: - panic(fmt.Sprintf("PROVIDER BUG: Set type %T not supported (%#v) for %s ", v, v, name)) - } -} - -func (w *attrWriterMap) SetBool(name schemaAttr, b bool) error { - w.m[string(name)] = fmt.Sprintf("%t", b) - return nil -} - -func (w *attrWriterMap) SetFloat64(name schemaAttr, f float64) error { - w.m[string(name)] = strconv.FormatFloat(f, 'g', -1, 64) - return nil -} - -func (w *attrWriterMap) SetList(name schemaAttr, l []interface{}) error { - panic(fmt.Sprintf("PROVIDER BUG: Cat set a list within a map for %s", name)) -} - -func (w *attrWriterMap) SetMap(name schemaAttr, m map[string]interface{}) error { - w.m[string(name)] = m - return nil - panic(fmt.Sprintf("PROVIDER BUG: Cat set a map within a map for %s", name)) -} - -func (w *attrWriterMap) SetSet(name schemaAttr, s *schema.Set) error { - panic(fmt.Sprintf("PROVIDER BUG: Cat set a set within a map for %s", name)) -} - -func (w *attrWriterMap) SetString(name schemaAttr, s string) error { - w.m[string(name)] = s - return nil -} - -func (w *attrWriterMap) ToMap() map[string]interface{} { - return w.m -} diff --git a/builtin/providers/consul/attr_writer_state.go b/builtin/providers/consul/attr_writer_state.go deleted file mode 100644 index 561d38d1d..000000000 --- a/builtin/providers/consul/attr_writer_state.go +++ /dev/null @@ -1,45 +0,0 @@ -package consul - -import "github.com/hashicorp/terraform/helper/schema" - -type attrWriterState struct { - d *schema.ResourceData -} - -func newStateWriter(d *schema.ResourceData) *attrWriterState { - return &attrWriterState{ - d: d, - } -} - -func (w *attrWriterState) BackingType() string { - return "state" -} - -func (w *attrWriterState) SetBool(name schemaAttr, b bool) error { - return stateSet(w.d, name, b) -} - -func (w *attrWriterState) SetID(id string) { - w.d.SetId(id) -} - -func (w *attrWriterState) SetFloat64(name schemaAttr, f float64) error { - return stateSet(w.d, name, f) -} - -func (w *attrWriterState) SetList(name schemaAttr, l []interface{}) error { - return stateSet(w.d, name, l) -} - -func (w *attrWriterState) SetMap(name schemaAttr, m map[string]interface{}) error { - return stateSet(w.d, name, m) -} - -func (w *attrWriterState) SetSet(name schemaAttr, s *schema.Set) error { - return stateSet(w.d, name, []interface{}{s}) -} - -func (w *attrWriterState) SetString(name schemaAttr, s string) error { - return stateSet(w.d, name, s) -}