mirror of
				https://github.com/k3s-io/kubernetes.git
				synced 2025-10-30 21:30:16 +00:00 
			
		
		
		
	godep restore pushd $GOPATH/src/github.com/appc/spec git co master popd go get go4.org/errorutil rm -rf Godeps godep save ./... git add vendor git add -f $(git ls-files --other vendor/) git co -- Godeps/LICENSES Godeps/.license_file_state Godeps/OWNERS
		
			
				
	
	
		
			30 lines
		
	
	
		
			734 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			30 lines
		
	
	
		
			734 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| package mesosutil
 | |
| 
 | |
| import (
 | |
| 	"os"
 | |
| 	"os/exec"
 | |
| 	"strings"
 | |
| 
 | |
| 	log "github.com/golang/glog"
 | |
| )
 | |
| 
 | |
| //TODO(jdef) copied from kubernetes/pkg/util/node.go
 | |
| func GetHostname(hostnameOverride string) string {
 | |
| 	hostname := hostnameOverride
 | |
| 	if hostname == "" {
 | |
| 		// Note: We use exec here instead of os.Hostname() because we
 | |
| 		// want the FQDN, and this is the easiest way to get it.
 | |
| 		fqdn, err := exec.Command("hostname", "-f").Output()
 | |
| 		if err != nil || len(fqdn) == 0 {
 | |
| 			log.Errorf("Couldn't determine hostname fqdn, failing back to hostname: %v", err)
 | |
| 			hostname, err = os.Hostname()
 | |
| 			if err != nil {
 | |
| 				log.Fatalf("Error getting hostname: %v", err)
 | |
| 			}
 | |
| 		} else {
 | |
| 			hostname = string(fqdn)
 | |
| 		}
 | |
| 	}
 | |
| 	return strings.TrimSpace(hostname)
 | |
| }
 |