mirror of
https://gitlab.com/arm-research/smarter/smarter-device-manager.git
synced 2025-04-19 04:48:40 +00:00
Compare commits
No commits in common. "master" and "v1.20.5" have entirely different histories.
@ -10,13 +10,15 @@ COPY . .
|
|||||||
|
|
||||||
RUN echo $PATH;export CGO_LDFLAGS_ALLOW='-Wl,--unresolved-symbols=ignore-in-object-files' && \
|
RUN echo $PATH;export CGO_LDFLAGS_ALLOW='-Wl,--unresolved-symbols=ignore-in-object-files' && \
|
||||||
go mod init arm.com/smarter-device-management && go mod tidy && go mod vendor && \
|
go mod init arm.com/smarter-device-management && go mod tidy && go mod vendor && \
|
||||||
CGO_ENABLED=0 go build -ldflags='-s -w -extldflags="-static"' .
|
go build -ldflags="-s -w" .
|
||||||
|
|
||||||
FROM scratch
|
FROM alpine
|
||||||
|
|
||||||
|
RUN apk update && apk upgrade
|
||||||
|
|
||||||
WORKDIR /root
|
WORKDIR /root
|
||||||
|
|
||||||
COPY conf.yaml /root/config/conf.yaml
|
COPY conf.yaml /root/config/conf.yaml
|
||||||
COPY --from=build /arm.com/smarter-device-management/smarter-device-management /usr/bin/smarter-device-management
|
COPY --from=build /arm.com/smarter-device-management/smarter-device-management /usr/bin/smarter-device-management
|
||||||
|
|
||||||
CMD ["/usr/bin/smarter-device-management","-logtostderr=true","-v=0"]
|
CMD ["smarter-device-management","-logtostderr=true","-v=0"]
|
||||||
|
36
main.go
36
main.go
@ -55,18 +55,9 @@ func init() {
|
|||||||
flag.Parse()
|
flag.Parse()
|
||||||
}
|
}
|
||||||
|
|
||||||
func readDevDirectory(dirToList string, allowedRecursions uint8) (files []string, err error) {
|
func readDevDirectory(dirToList string) (files []string, err error) {
|
||||||
var foundFiles []string
|
var foundFiles []string
|
||||||
|
|
||||||
fType, err := os.Stat(dirToList)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if !fType.IsDir() {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
f, err := os.Open(dirToList)
|
f, err := os.Open(dirToList)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -79,36 +70,19 @@ func readDevDirectory(dirToList string, allowedRecursions uint8) (files []string
|
|||||||
f.Close()
|
f.Close()
|
||||||
for _, subDir := range files {
|
for _, subDir := range files {
|
||||||
foundFiles = append(foundFiles, subDir)
|
foundFiles = append(foundFiles, subDir)
|
||||||
if allowedRecursions > 0 {
|
filesDir, err := readDevDirectory(dirToList+"/"+subDir)
|
||||||
filesDir, err := readDevDirectory(dirToList+"/"+subDir,allowedRecursions-1)
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
for _, fileName := range filesDir {
|
for _, fileName := range filesDir {
|
||||||
foundFiles = append(foundFiles, subDir+"/"+fileName)
|
foundFiles = append(foundFiles, subDir+"/"+fileName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return foundFiles, nil
|
return foundFiles, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func sanitizeName(path string) string {
|
func sanitizeName(path string) string {
|
||||||
sanitizeChar := func(r rune) rune {
|
return strings.Replace(path, "/", "_" ,-1)
|
||||||
switch {
|
|
||||||
case r >= 'A' && r <= 'Z':
|
|
||||||
return r
|
|
||||||
case r >= 'a' && r <= 'z':
|
|
||||||
return r
|
|
||||||
case r >= '0' && r <= '9':
|
|
||||||
return r
|
|
||||||
case r == '_':
|
|
||||||
return r
|
|
||||||
case r == '-':
|
|
||||||
return r
|
|
||||||
}
|
|
||||||
return '_'
|
|
||||||
}
|
|
||||||
return strings.Map(sanitizeChar, path)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func findDevicesPattern(listDevices []string, pattern string) ([]string,error) {
|
func findDevicesPattern(listDevices []string, pattern string) ([]string,error) {
|
||||||
@ -144,13 +118,13 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
glog.V(0).Info("Reading existing devices on /dev")
|
glog.V(0).Info("Reading existing devices on /dev")
|
||||||
ExistingDevices, err := readDevDirectory("/dev",10)
|
ExistingDevices, err := readDevDirectory("/dev")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf(err.Error())
|
glog.Errorf(err.Error())
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
ExistingDevicesSys, err := readDevDirectory("/sys/devices",0)
|
ExistingDevicesSys, err := readDevDirectory("/sys/devices")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf(err.Error())
|
glog.Errorf(err.Error())
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
@ -15,7 +15,7 @@ spec:
|
|||||||
nodeName: smarter-jetson-xavier-4bcc2584
|
nodeName: smarter-jetson-xavier-4bcc2584
|
||||||
containers:
|
containers:
|
||||||
- name: smarter-device-manager
|
- name: smarter-device-manager
|
||||||
image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.20.11
|
image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.20.5
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
securityContext:
|
securityContext:
|
||||||
allowPrivilegeEscalation: false
|
allowPrivilegeEscalation: false
|
||||||
|
@ -15,7 +15,7 @@ spec:
|
|||||||
nodeName: <replace with node to run>
|
nodeName: <replace with node to run>
|
||||||
containers:
|
containers:
|
||||||
- name: smarter-device-manager
|
- name: smarter-device-manager
|
||||||
image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.20.11
|
image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.20.5
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
securityContext:
|
securityContext:
|
||||||
allowPrivilegeEscalation: false
|
allowPrivilegeEscalation: false
|
||||||
|
@ -15,7 +15,7 @@ spec:
|
|||||||
nodeName: <replace with node to run>
|
nodeName: <replace with node to run>
|
||||||
containers:
|
containers:
|
||||||
- name: smarter-device-manager
|
- name: smarter-device-manager
|
||||||
image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.20.11
|
image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.20.5
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
securityContext:
|
securityContext:
|
||||||
allowPrivilegeEscalation: false
|
allowPrivilegeEscalation: false
|
||||||
|
@ -34,7 +34,7 @@ spec:
|
|||||||
dnsPolicy: ClusterFirstWithHostNet
|
dnsPolicy: ClusterFirstWithHostNet
|
||||||
containers:
|
containers:
|
||||||
- name: smarter-device-manager
|
- name: smarter-device-manager
|
||||||
image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.20.11
|
image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.20.5
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
securityContext:
|
securityContext:
|
||||||
allowPrivilegeEscalation: false
|
allowPrivilegeEscalation: false
|
||||||
|
@ -34,7 +34,7 @@ spec:
|
|||||||
dnsPolicy: ClusterFirstWithHostNet
|
dnsPolicy: ClusterFirstWithHostNet
|
||||||
containers:
|
containers:
|
||||||
- name: smarter-device-manager
|
- name: smarter-device-manager
|
||||||
image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.20.11
|
image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.20.5
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
securityContext:
|
securityContext:
|
||||||
allowPrivilegeEscalation: false
|
allowPrivilegeEscalation: false
|
||||||
|
@ -34,7 +34,7 @@ spec:
|
|||||||
dnsPolicy: ClusterFirstWithHostNet
|
dnsPolicy: ClusterFirstWithHostNet
|
||||||
containers:
|
containers:
|
||||||
- name: smarter-device-manager
|
- name: smarter-device-manager
|
||||||
image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.20.11
|
image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.20.5
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
securityContext:
|
securityContext:
|
||||||
allowPrivilegeEscalation: false
|
allowPrivilegeEscalation: false
|
||||||
|
@ -34,7 +34,7 @@ spec:
|
|||||||
dnsPolicy: ClusterFirstWithHostNet
|
dnsPolicy: ClusterFirstWithHostNet
|
||||||
containers:
|
containers:
|
||||||
- name: smarter-device-manager
|
- name: smarter-device-manager
|
||||||
image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.20.11
|
image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.20.5
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
securityContext:
|
securityContext:
|
||||||
allowPrivilegeEscalation: false
|
allowPrivilegeEscalation: false
|
||||||
|
@ -34,7 +34,7 @@ spec:
|
|||||||
dnsPolicy: ClusterFirstWithHostNet
|
dnsPolicy: ClusterFirstWithHostNet
|
||||||
containers:
|
containers:
|
||||||
- name: smarter-device-manager
|
- name: smarter-device-manager
|
||||||
image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.20.11
|
image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.20.5
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
securityContext:
|
securityContext:
|
||||||
allowPrivilegeEscalation: false
|
allowPrivilegeEscalation: false
|
||||||
|
@ -34,7 +34,7 @@ spec:
|
|||||||
dnsPolicy: ClusterFirstWithHostNet
|
dnsPolicy: ClusterFirstWithHostNet
|
||||||
containers:
|
containers:
|
||||||
- name: smarter-device-manager
|
- name: smarter-device-manager
|
||||||
image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.20.11
|
image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.20.5
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
securityContext:
|
securityContext:
|
||||||
allowPrivilegeEscalation: false
|
allowPrivilegeEscalation: false
|
||||||
|
Loading…
x
Reference in New Issue
Block a user