Skip to content
Snippets Groups Projects
Commit d6b05cd0 authored by Christopher Harm's avatar Christopher Harm
Browse files

Adding help diagnostics for swagger.local

parent 84a617d3
No related branches found
No related tags found
No related merge requests found
Pipeline #178142 waiting for manual action
......@@ -556,17 +556,33 @@ func setupHostsFile() error {
color.New(color.FgGreen).Printf("Cluster Ingress is at: 'http://%s'\n", ip)
if !hostsfile.Has(ip, "kubernetes.local") {
if hostsfile.HasHostname("kubernetes.local") {
correctHostsFile := true
if err := validateHostsFileEntry(hostsfile, ip, "kubernetes.local"); err != nil {
correctHostsFile = false
}
if err := validateHostsFileEntry(hostsfile, ip, "swagger.local"); err != nil {
correctHostsFile = false
}
if correctHostsFile {
color.Green("/etc/hosts file is configured correctly.")
}
return nil
}
func validateHostsFileEntry(hostsfile hostsfile.Hosts, ip, host string) error {
if !hostsfile.Has(ip, host) {
if hostsfile.HasHostname(host) {
color.Red("ACTION REQUIRED: host ip address has changed. Please clean up your /etc/hosts file")
color.New(color.FgRed).Printf("\tKubernetes entry: \"%s kubernetes.local\"\n", ip)
color.New(color.FgRed).Printf("\tEntry: \"%s %s\"\n", ip, host)
return fmt.Errorf("/etc/hosts entry ip has change")
}
color.Red("ACTION REQUIRED: Please modify your /etc/hosts file!")
color.New(color.FgRed).Printf("\tRun: 'echo \"%s kubernetes.local\" | sudo tee -a /etc/hosts'\n", ip)
} else {
color.Green("/etc/hosts file is configured correctly.")
color.New(color.FgRed).Printf("\tRun: 'echo \"%s %s\" | sudo tee -a /etc/hosts'\n", ip, host)
return fmt.Errorf("/etc/hosts entry is missing")
}
return nil
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment