func (m *yamlManager) CreateConfigIfNotExists(uaaOrigin string) error {
	if FileOrDirectoryExists(m.ConfigDir) {
		lo.G.Infof("Config directory %s already exists, skipping creation", m.ConfigDir)
		return nil
	}
	if err := os.MkdirAll(m.ConfigDir, 0755); err != nil {
		lo.G.Errorf("Error creating config directory %s. Error : %s", m.ConfigDir, err)
		return fmt.Errorf("cannot create directory %s: %v", m.ConfigDir, err)
	}
	lo.G.Infof("Config directory %s created", m.ConfigDir)

	asgDir := path.Join(m.ConfigDir, "asgs")
	if err := os.MkdirAll(asgDir, 0755); err != nil {
		lo.G.Errorf("Error creating config directory %s. Error : %s", asgDir, err)
		return fmt.Errorf("cannot create directory %s: %v", asgDir, err)
	}
	lo.G.Infof("ASG directory %s created", asgDir)

	asgDir = path.Join(m.ConfigDir, "default_asgs")
	if err := os.MkdirAll(asgDir, 0755); err != nil {
		lo.G.Errorf("Error creating config directory %s. Error : %s", asgDir, err)
		return fmt.Errorf("cannot create directory %s: %v", asgDir, err)
	}
	lo.G.Infof("ASG directory %s created", asgDir)

	orgQuotasDir := path.Join(m.ConfigDir, "org_quotas")
	if err := os.MkdirAll(orgQuotasDir, 0755); err != nil {
		lo.G.Errorf("Error creating config directory %s. Error : %s", orgQuotasDir, err)
		return fmt.Errorf("cannot create directory %s: %v", orgQuotasDir, err)
	}
	lo.G.Infof("OrgQuotas directory %s created", orgQuotasDir)

	if err := m.SaveGlobalConfig(&GlobalConfig{}); err != nil {
		return err
	}
	if err := WriteFile(fmt.Sprintf("%s/ldap.yml", m.ConfigDir), &LdapConfig{TLS: false, Origin: uaaOrigin}); err != nil {
		return err
	}

	if err := WriteFile(fmt.Sprintf("%s/orgs.yml", m.ConfigDir), &Orgs{
		EnableDeleteOrgs: true,
		ProtectedOrgs:    DefaultProtectedOrgs,
	}); err != nil {
		return err
	}
	if err := WriteFile(fmt.Sprintf("%s/spaceDefaults.yml", m.ConfigDir), struct {
		Developer UserMgmt `yaml:"space-developer"`
		Manager   UserMgmt `yaml:"space-manager"`
		Auditor   UserMgmt `yaml:"space-auditor"`
	}{}); err != nil {
		return err
	}
	return nil
}
func (m *yamlManager) CreateConfigIfNotExists(uaaOrigin string) error {
	if FileOrDirectoryExists(m.ConfigDir) {
		lo.G.Infof("Config directory %s already exists, skipping creation", m.ConfigDir)
		return nil
	}
	if err := os.MkdirAll(m.ConfigDir, 0755); err != nil {
		lo.G.Errorf("Error creating config directory %s. Error : %s", m.ConfigDir, err)
		return fmt.Errorf("cannot create directory %s: %v", m.ConfigDir, err)
	}
	lo.G.Infof("Config directory %s created", m.ConfigDir)

	asgDir := path.Join(m.ConfigDir, "asgs")
	if err := os.MkdirAll(asgDir, 0755); err != nil {
		lo.G.Errorf("Error creating config directory %s. Error : %s", asgDir, err)
		return fmt.Errorf("cannot create directory %s: %v", asgDir, err)
	}
	lo.G.Infof("ASG directory %s created", asgDir)

	asgDir = path.Join(m.ConfigDir, "default_asgs")
	if err := os.MkdirAll(asgDir, 0755); err != nil {
		lo.G.Errorf("Error creating config directory %s. Error : %s", asgDir, err)
		return fmt.Errorf("cannot create directory %s: %v", asgDir, err)
	}
	lo.G.Infof("ASG directory %s created", asgDir)

	orgQuotasDir := path.Join(m.ConfigDir, "org_quotas")
	if err := os.MkdirAll(orgQuotasDir, 0755); err != nil {
		lo.G.Errorf("Error creating config directory %s. Error : %s", orgQuotasDir, err)
		return fmt.Errorf("cannot create directory %s: %v", orgQuotasDir, err)
	}
	lo.G.Infof("OrgQuotas directory %s created", orgQuotasDir)

	if err := m.SaveGlobalConfig(&GlobalConfig{}); err != nil {
		return err
	}
	if err := WriteFile(fmt.Sprintf("%s/ldap.yml", m.ConfigDir), &LdapConfig{TLS: false, Origin: uaaOrigin}); err != nil {
		return err
	}

	if err := WriteFile(fmt.Sprintf("%s/orgs.yml", m.ConfigDir), &Orgs{
		EnableDeleteOrgs: true,
		ProtectedOrgs:    DefaultProtectedOrgs,
	}); err != nil {
		return err
	}
	if err := WriteFile(fmt.Sprintf("%s/spaceDefaults.yml", m.ConfigDir), struct {
		Developer UserMgmt `yaml:"space-developer"`
		Manager   UserMgmt `yaml:"space-manager"`
		Auditor   UserMgmt `yaml:"space-auditor"`
	}{}); err != nil {
		return err
	}
	return nil
}
// CreateConfigIfNotExists initializes a new configuration directory.
// If the specified configuration directory already exists, it is left unmodified.