Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] shortName not correctly discovered #723

Closed
Cellebyte opened this issue Jan 13, 2024 · 0 comments · Fixed by #724 or smartxworks/cluster-api-provider-elf#173
Closed

[Bug] shortName not correctly discovered #723

Cellebyte opened this issue Jan 13, 2024 · 0 comments · Fixed by #724 or smartxworks/cluster-api-provider-elf#173

Comments

@Cellebyte
Copy link
Collaborator

if len(hostParts) > 1 {

This should be >= so short host names also work.

As playground currently does not work here the example code.

// You can edit this code!
// Click here and start typing.
package main

import (
	"fmt"
	"strings"
)

func getShortname(hostname string) (string, error) {
	if len(hostname) == 0 {
		return "", fmt.Errorf("unable to find shortname from %s as len is 0 %d", hostname, len(hostname))
	}
	hostParts := strings.Split(hostname, ".")
	if len(hostParts) >= 1 {
		return hostParts[0], nil
	}
	return "", fmt.Errorf("unable to find shortname from %s, as hostParts are %v", hostname, hostParts)
}

func main() {
	fmt.Println(getShortname("wuerfelchen-w-1"))
}
@Cellebyte Cellebyte changed the title [Bug] shortName not correctly discoverd [Bug] shortName not correctly discovered Jan 13, 2024
thebsdbox added a commit that referenced this issue Jan 13, 2024
fix #723 and allow short hostnames as well
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant