Skip to content

Commit

Permalink
add validator to platform level
Browse files Browse the repository at this point in the history
  • Loading branch information
reddec committed Jul 20, 2020
1 parent 2224aa3 commit 3093b33
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
8 changes: 7 additions & 1 deletion application/platform/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ import (

var allowedName = regexp.MustCompile("^[a-zA-Z0-9._-]{1,255}$")

func New(configFile string) (*platform, error) {
type Validator interface {
Inspect(lambda string, request *types.Request) error
}

func New(configFile string, validator Validator) (*platform, error) {
var config application.Config
err := config.ReadFile(configFile)
if err != nil && !os.IsNotExist(err) {
Expand All @@ -25,6 +29,7 @@ func New(configFile string) (*platform, error) {
pl := &platform{
configLocation: configFile,
config: config,
validator: validator,
}
return pl, pl.SetConfig(config)
}
Expand All @@ -35,6 +40,7 @@ type platform struct {
config application.Config
configLocation string
byUID map[string]record
validator Validator
}

type record struct {
Expand Down
4 changes: 2 additions & 2 deletions assets/bindata.go
Git LFS file not shown
9 changes: 4 additions & 5 deletions cmd/trusted-cgi/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,23 +131,22 @@ func run(ctx context.Context, config Config) error {
} else if config.DisableChroot {
defCfg.User = ""
}

basePlatform, err := platform.New(filepath.Join(config.Dir, internal2.ProjectManifest))
policies, err := policy.New(policy.FileConfig(config.Policies.Config))
if err != nil {
return err
}

queueFactory, err := config.Queues.Factory()
basePlatform, err := platform.New(filepath.Join(config.Dir, internal2.ProjectManifest), policies)
if err != nil {
return err
}

queueManager, err := queuemanager.New(ctx, queuemanager.FileConfig(config.Queues.Config), basePlatform, queueFactory)
queueFactory, err := config.Queues.Factory()
if err != nil {
return err
}

policies, err := policy.New(policy.FileConfig(config.Policies.Config))
queueManager, err := queuemanager.New(ctx, queuemanager.FileConfig(config.Queues.Config), basePlatform, queueFactory)
if err != nil {
return err
}
Expand Down

0 comments on commit 3093b33

Please sign in to comment.