Skip to content

Commit 8acd06c

Browse files
committed
feat(api): pilot the context directory to use when parsing files
1 parent 416d2b9 commit 8acd06c

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

action.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ branding:
88
inputs:
99
file:
1010
description: 'Configuration file to use for setting up CTFd. If let empty, will default the values and look for secrets in expected environment variables. For more info, refers to the documentation.'
11+
dir:
12+
description: 'The directory to parse from.'
1113
url:
1214
description: 'URL to reach the CTFd instance.'
1315
required: true

cmd/ctfd-setup/main.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@ func main() {
3939
EnvVars: []string{"FILE", "PLUGIN_FILE"},
4040
Category: management,
4141
},
42+
&cli.StringFlag{
43+
Name: "dir",
44+
Usage: "The directory to parse from.",
45+
EnvVars: []string{"DIRECTORY"},
46+
Category: management,
47+
Destination: &ctfdsetup.Directory,
48+
},
4249
&cli.StringFlag{
4350
Name: "url",
4451
Usage: "URL to reach the CTFd instance.",

file.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,16 @@ package ctfdsetup
22

33
import (
44
"os"
5+
"path/filepath"
56

67
"github.com/invopop/jsonschema"
78
"gopkg.in/yaml.v3"
89
)
910

11+
var (
12+
Directory string
13+
)
14+
1015
type File struct {
1116
Name string `yaml:"-" json:"-" jsonschema:"-"`
1217
Content []byte `yaml:"-" json:"-" jsonschema:"-"`
@@ -31,7 +36,7 @@ func (file *File) UnmarshalYAML(node *yaml.Node) error {
3136
return nil
3237
}
3338

34-
fc, err := os.ReadFile(*lfiv.FromFile)
39+
fc, err := os.ReadFile(filepath.Join(Directory, *lfiv.FromFile))
3540
if err != nil {
3641
return err
3742
}

0 commit comments

Comments
 (0)