func splitConfigToDelete(config string) (configType string, name string, err error) {
	if !strings.Contains(config, "/") {
		err = errors.New("config " + config + " does not contain '" + deleteDelimiter + "' delimiter")
		return
	}
	split := strings.Split(config, "/")
	if len(split) != 2 {
		err = errors.New("config " + config + " contains more than one '" + deleteDelimiter + "' delimiter")
		return
	}
	return split[0], split[1], nil
}
splitConfigToDelete gets one line of the delete.yaml as input and splits it into config type and name
E.g.: dashboards/my-dashboard -> config type: dashboard, name: my-dashboard
package delete
import (
	"errors"
	"path/filepath"
	"strings"
	"github.com/dynatrace-oss/dynatrace-monitoring-as-code/pkg/api"
	"github.com/dynatrace-oss/dynatrace-monitoring-as-code/pkg/config"
	"github.com/dynatrace-oss/dynatrace-monitoring-as-code/pkg/util"
	"github.com/spf13/afero"
	"gopkg.in/yaml.v2"
)
const deleteDelimiter = "/"
const deleteFileName = "delete.yaml"
type deleteYaml struct {
	Delete interface{}
}
func LoadConfigsToDelete(fs afero.Fs, apis map[string]api.Api, path string) (configs []config.Config, err error) {
	result := make([]config.Config, 0)
	deleteFilePath := filepath.Join(path, deleteFileName)
	data, err := afero.ReadFile(fs, deleteFilePath)
	if err != nil {
		util.Log.Info("There is no delete file %s found in %s. Skipping delete config.", deleteFileName, deleteFilePath)
		return result, nil
	}
	list, err := unmarshalDeleteYaml(string(data), deleteFileName)
	if util.CheckError(err, deleteFileName+" file content was invalid") {
		return configs, err
	}
	for _, element := range list {
		configType, name, err := splitConfigToDelete(element)
		if util.CheckError(err, "deletion failed") {
			return configs, err
		}
		apiName, validConfig := apis[configType]
		if !validConfig {
			return configs, errors.New("config type " + configType + " was not valid")
		}
		properties := make(map[string]map[string]string)
		properties[name] = make(map[string]string)
		properties[name]["name"] = name
		configForDeletion := config.NewConfigForDelete(name, "delete.yaml", properties, apiName)
		result = append(result, configForDeletion)
	}
	return result, nil
}