@@ -28,6 +28,7 @@ func (s *EdgeRuntimeAPI) Deploy(ctx context.Context, functionConfig config.Funct
28
28
if s .eszip != nil {
29
29
return s .UpsertFunctions (ctx , functionConfig )
30
30
}
31
+ // Convert all paths in functions config to relative when using api deploy
31
32
var toDeploy []api.FunctionDeployMetadata
32
33
for slug , fc := range functionConfig {
33
34
if ! fc .Enabled {
@@ -36,13 +37,13 @@ func (s *EdgeRuntimeAPI) Deploy(ctx context.Context, functionConfig config.Funct
36
37
}
37
38
meta := api.FunctionDeployMetadata {
38
39
Name : & slug ,
39
- EntrypointPath : filepath . ToSlash (fc .Entrypoint ),
40
- ImportMapPath : cast .Ptr (filepath . ToSlash (fc .ImportMap )),
40
+ EntrypointPath : toRelPath (fc .Entrypoint ),
41
+ ImportMapPath : cast .Ptr (toRelPath (fc .ImportMap )),
41
42
VerifyJwt : & fc .VerifyJWT ,
42
43
}
43
44
files := make ([]string , len (fc .StaticFiles ))
44
45
for i , sf := range fc .StaticFiles {
45
- files [i ] = filepath . ToSlash (sf )
46
+ files [i ] = toRelPath (sf )
46
47
}
47
48
meta .StaticPatterns = & files
48
49
toDeploy = append (toDeploy , meta )
@@ -57,16 +58,27 @@ func (s *EdgeRuntimeAPI) Deploy(ctx context.Context, functionConfig config.Funct
57
58
return s .bulkUpload (ctx , toDeploy , fsys )
58
59
}
59
60
61
+ func toRelPath (fp string ) string {
62
+ if filepath .IsAbs (fp ) {
63
+ if cwd , err := os .Getwd (); err == nil {
64
+ if relPath , err := filepath .Rel (cwd , fp ); err == nil {
65
+ fp = relPath
66
+ }
67
+ }
68
+ }
69
+ return filepath .ToSlash (fp )
70
+ }
71
+
60
72
func (s * EdgeRuntimeAPI ) bulkUpload (ctx context.Context , toDeploy []api.FunctionDeployMetadata , fsys fs.FS ) error {
61
73
jq := queue .NewJobQueue (s .maxJobs )
62
74
toUpdate := make ([]api.BulkUpdateFunctionBody , len (toDeploy ))
63
75
for i , meta := range toDeploy {
64
- fmt .Fprintln (os .Stderr , "Deploying Function:" , * meta .Name )
65
76
param := api.V1DeployAFunctionParams {
66
77
Slug : meta .Name ,
67
78
BundleOnly : cast .Ptr (true ),
68
79
}
69
80
bundle := func () error {
81
+ fmt .Fprintln (os .Stderr , "Deploying Function:" , * meta .Name )
70
82
resp , err := s .upload (ctx , param , meta , fsys )
71
83
if err != nil {
72
84
return err
0 commit comments