Skip to content

Commit

Permalink
fix: fix file paths in configuration files on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
suzuki-shunsuke committed Feb 6, 2025
1 parent cbf9027 commit c795d7d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"io"
"path"
"path/filepath"

"github.com/sirupsen/logrus"
"github.com/spf13/afero"
Expand Down Expand Up @@ -68,6 +69,17 @@ func Validate(cfg *Config) error {
return nil
}

func ConvertPath(cfg *Config) {
for _, exclude := range cfg.Excludes {
convertPath(exclude)
}
}

func convertPath(exclude *Exclude) {
exclude.WorkflowFilePath = filepath.FromSlash(exclude.WorkflowFilePath)
exclude.ActionFilePath = filepath.FromSlash(exclude.ActionFilePath)
}

func validate(exclude *Exclude) error { //nolint:cyclop
if exclude.PolicyName == "" {
return errors.New(`policy_name is required`)
Expand Down
1 change: 1 addition & 0 deletions pkg/controller/act/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ func (c *Controller) readConfig(cfg *config.Config, cfgFilePath string) error {
"config_file": cfgFilePath,
}))
}
config.ConvertPath(cfg)
}
return nil
}
1 change: 1 addition & 0 deletions pkg/controller/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ func (c *Controller) readConfig(cfg *config.Config, cfgFilePath string) error {
"config_file": cfgFilePath,
}))
}
config.ConvertPath(cfg)
}
return nil
}

0 comments on commit c795d7d

Please sign in to comment.