provider.go 686 B

123456789101112131415161718192021
  1. package resource
  2. type Provider interface {
  3. NewInstance(string) (Instance, error)
  4. }
  5. // TranslatedProvider manipulates resource locations, so as to allow
  6. // sandboxing, or relative paths for example.
  7. type TranslatedProvider struct {
  8. // The underlying Provider.
  9. BaseProvider Provider
  10. // Some location used in calculating final locations.
  11. BaseLocation string
  12. // Function that takes BaseLocation, and the caller location and returns
  13. // the location to be used with the BaseProvider.
  14. JoinLocations func(base, rel string) string
  15. }
  16. func (me TranslatedProvider) NewInstance(rel string) (Instance, error) {
  17. return me.BaseProvider.NewInstance(me.JoinLocations(me.BaseLocation, rel))
  18. }