
This commit removes the configuration files for Godeps as well as the vendored dependencies, replacing them with go modules, Go's built-in dependency management system. This dramatically slims down the size of the repo (from 25M to 324K, discounting the .git directory) and greatly speeds up cloning times. This will also provide mechanisms for managing versions of any auxiliary tools (e.g. linters), creating a reproducible environment for developers and CI/CD efforts. This also modifies the Makefile to take into account that the repo no longer needs to be cloned into the GOPATH. Change-Id: I2213792cc3ce81831d5b835f2252ca6f137e0086
39 lines
901 B
Go
39 lines
901 B
Go
package util
|
|
|
|
import (
|
|
"fmt"
|
|
"net"
|
|
"os"
|
|
"strings"
|
|
|
|
"opendev.org/airship/kubernetes-entrypoint/logger"
|
|
"opendev.org/airship/kubernetes-entrypoint/util/env"
|
|
)
|
|
|
|
func GetIp() (string, error) {
|
|
var iface string
|
|
if iface = os.Getenv("INTERFACE_NAME"); iface == "" {
|
|
return "", fmt.Errorf("Environment variable INTERFACE_NAME not set")
|
|
}
|
|
i, err := net.InterfaceByName(iface)
|
|
if err != nil {
|
|
return "", fmt.Errorf("Cannot get iface: %v", err)
|
|
}
|
|
|
|
address, err := i.Addrs()
|
|
if err != nil || len(address) == 0 {
|
|
return "", fmt.Errorf("Cannot get ip: %v", err)
|
|
}
|
|
//Take first element to get rid of subnet
|
|
ip := strings.Split(address[0].String(), "/")[0]
|
|
return ip, nil
|
|
}
|
|
|
|
func ContainsSeparator(envString string, kind string) bool {
|
|
if strings.Contains(envString, env.Separator) {
|
|
logger.Error.Printf("%s doesn't accept namespace: %s", kind, envString)
|
|
return true
|
|
}
|
|
return false
|
|
}
|