func addResources()

in scripts/check_importer_supports_engine/main.go [117:156]


func addResources(path string, unsupported map[string]bool) error {
	fn := func(path string, info os.FileInfo, err error) error {
		if err != nil {
			return fmt.Errorf("walk path %q: %v", path, err)
		}

		if filepath.Ext(path) != ".tf" {
			return nil
		}

		b, err := ioutil.ReadFile(path)
		if err != nil {
			return fmt.Errorf("read file %q: %v", path, err)
		}
		match := resourceRE.FindAllStringSubmatch(string(b), -1)
		for _, m := range match {
			resource := m[len(m)-1]
			if _, ok := unsupported[resource]; ok {
				continue
			}

			// Skip if it's supported or not importable.
			_, supported := tfimport.Importers[resource]
			_, unimportable := tfimport.Unimportable[resource]
			if supported || unimportable {
				continue
			}

			unsupported[resource] = true
		}

		return nil
	}

	if err := filepath.Walk(path, fn); err != nil {
		return fmt.Errorf("filepath.Walk = %v", err)
	}

	return nil
}