func ConvertSpaceName(name string, existing set.Strings) string {
	// Lower case and replace spaces with dashes.
	name = strings.Replace(name, " ", "-", -1)
	name = strings.ToLower(name)

	// Remove any character not in the set "-", "a-z", "0-9".
	name = invalidSpaceNameChars.ReplaceAllString(name, "")

	// Remove any dashes at the beginning and end.
	name = dashPrefix.ReplaceAllString(name, "")
	name = dashSuffix.ReplaceAllString(name, "")

	// Replace multiple dashes with a single dash.
	name = multipleDashes.ReplaceAllString(name, "-")

	// If the name had only invalid characters, give it a new name.
	if name == "" {
		name = "empty"
	}

	// If this name is in use add a numerical suffix.
	if existing.Contains(name) {
		counter := 2
		for existing.Contains(fmt.Sprintf("%s-%d", name, counter)) {
			counter++
		}
		name = fmt.Sprintf("%s-%d", name, counter)
	}

	return name
}
// ConvertSpaceName is used to massage provider-sourced (i.e. MAAS)
// space names so that they conform to Juju's space name rules.
ConvertSpaceName is used to massage provider-sourced
space names so that they conform to Juju's space name rules.
// ConvertSpaceName is used to massage provider - sourced ( i . e . MAAS ) // space names so that they conform to Juju ' s space name rules .
func ConvertSpaceName(name string, existing set.Strings) string {
	name = strings.Replace(name, " ", "-", -1)
	name = strings.ToLower(name)
	name = invalidSpaceNameChars.ReplaceAllString(name, "")
	name = dashPrefix.ReplaceAllString(name, "")
	name = dashSuffix.ReplaceAllString(name, "")
	name = multipleDashes.ReplaceAllString(name, "-")
	if name == "" {
		name = "empty"
	}
	if existing.Contains(name) {
		counter := 2
		for existing.Contains(fmt.Sprintf("%s-%d", name, counter)) {
			counter++
		}
		name = fmt.Sprintf("%s-%d", name, counter)
	}
	return name
}
func ConvertSpaceName ( name string , existing set . Strings ) string { name = strings . Replace ( name , " " , " " , - 1 ) name = strings . ToLower ( name ) name = invalidSpaceNameChars . ReplaceAllString ( name , " " ) name = dashPrefix . ReplaceAllString ( name , " " ) name = dashSuffix . ReplaceAllString ( name , " " ) name = multipleDashes . ReplaceAllString ( name , " " ) if name == " " { name = " " } if existing . Contains ( name ) { counter := 2 for existing . Contains ( fmt . Sprintf ( " " , name , counter ) ) { counter ++ } name = fmt . Sprintf ( " " , name , counter ) } return name }
ConvertSpaceName is used to massage provider-sourced
space names so that they conform to Juju's space name rules.
ConvertSpaceName is used to massage provider - sourced space names so that they conform to Juju ' s space name rules .
// Lower case and replace spaces with dashes. // Remove any character not in the set "-", "a-z", "0-9". // Remove any dashes at the beginning and end. // Replace multiple dashes with a single dash. // If the name had only invalid characters, give it a new name. // If this name is in use add a numerical suffix.