FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
lambda-runtime-init/lambda/agents/agent.go at localstack · developer-guy/lambda-runtime-init · GitHub
developer-guy
/
lambda-runtime-init
Public
forked from
localstack/lambda-runtime-init
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
lambda-runtime-init
/
lambda
/
agents
/
agent.go
Copy path
More file actions
More file actions
Latest commit
History
History
History
49 lines (41 loc) · 1.29 KB
Breadcrumbs
lambda-runtime-init
/
lambda
/
agents
/
agent.go
Copy path
File metadata and controls
49 lines (41 loc) · 1.29 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
package
agents
import
(
"os"
"path"
"path/filepath"
log
"github.com/sirupsen/logrus"
)
// ListExternalAgentPaths return a list of external agents found in a given directory
func
ListExternalAgentPaths
(
dir
string
,
root
string
) []
string
{
var
agentPaths
[]
string
if
!
isCanonical
(
dir
)
||
!
isCanonical
(
root
) {
log
.
Warningf
(
"Agents base paths are not absolute and in canonical form: %s, %s"
,
dir
,
root
)
return
agentPaths
}
fullDir
:=
path
.
Join
(
root
,
dir
)
files
,
err
:=
os
.
ReadDir
(
fullDir
)
if
err
!=
nil
{
if
os
.
IsNotExist
(
err
) {
log
.
Infof
(
"The extension's directory %q does not exist, assuming no extensions to be loaded."
,
fullDir
)
}
else
{
// TODO - Should this return an error rather than ignore failing to load?
log
.
WithError
(
err
).
Error
(
"Cannot list external agents"
)
}
return
agentPaths
}
for
_
,
file
:=
range
files
{
if
!
file
.
IsDir
() {
// The returned path is absolute wrt to `root`. This allows
// to exec the agents in their own mount namespace
p
:=
path
.
Join
(
"/"
,
dir
,
file
.
Name
())
agentPaths
=
append
(
agentPaths
,
p
)
}
}
return
agentPaths
}
func
isCanonical
(
path
string
)
bool
{
absPath
,
err
:=
filepath
.
Abs
(
path
)
return
err
==
nil
&&
absPath
==
path
}
Back
|
FazBrowse Home
|
New Git URL