
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
59 lines
1.3 KiB
Go
59 lines
1.3 KiB
Go
package socket
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
entry "opendev.org/airship/kubernetes-entrypoint/entrypoint"
|
|
"opendev.org/airship/kubernetes-entrypoint/logger"
|
|
"opendev.org/airship/kubernetes-entrypoint/util"
|
|
"opendev.org/airship/kubernetes-entrypoint/util/env"
|
|
)
|
|
|
|
const (
|
|
NonExistingErrorFormat = "%s doesn't exists"
|
|
NoPermsErrorFormat = "I have no permission to %s"
|
|
NamespaceNotSupported = "Socket doesn't accept namespace"
|
|
)
|
|
|
|
type Socket struct {
|
|
name string
|
|
}
|
|
|
|
func init() {
|
|
socketEnv := fmt.Sprintf("%sSOCKET", entry.DependencyPrefix)
|
|
if util.ContainsSeparator(socketEnv, "Socket") {
|
|
logger.Error.Printf(NamespaceNotSupported)
|
|
os.Exit(1)
|
|
}
|
|
if socketDeps := env.SplitEnvToDeps(socketEnv); socketDeps != nil {
|
|
if len(socketDeps) > 0 {
|
|
for _, dep := range socketDeps {
|
|
entry.Register(NewSocket(dep.Name))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
func NewSocket(name string) Socket {
|
|
return Socket{name: name}
|
|
}
|
|
|
|
func (s Socket) IsResolved(entrypoint entry.EntrypointInterface) (bool, error) {
|
|
_, err := os.Stat(s.name)
|
|
if err == nil {
|
|
return true, nil
|
|
}
|
|
if os.IsNotExist(err) {
|
|
return false, fmt.Errorf(NonExistingErrorFormat, s)
|
|
}
|
|
if os.IsPermission(err) {
|
|
return false, fmt.Errorf(NoPermsErrorFormat, s)
|
|
}
|
|
return false, err
|
|
}
|
|
|
|
func (s Socket) String() string {
|
|
return fmt.Sprintf("Socket %s", s.name)
|
|
}
|