Skip to content

Commit

Permalink
Load configs and directories from the working directory (#1952)
Browse files Browse the repository at this point in the history
* Load configuration and needed directories from the working directory

* update check

---------

Co-authored-by: Raúl Barroso <[email protected]>
  • Loading branch information
hariso and raulb authored Nov 8, 2024
1 parent 977b037 commit 55ebed9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
5 changes: 1 addition & 4 deletions cmd/cli/pipelines_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,7 @@ func (pi *PipelinesInit) Run() error {

fmt.Printf(`Your pipeline has been initialized and created at %s.
To run the pipeline, execute:
conduit --pipelines.path %s`,
pi.configFilePath(), pi.configFilePath())
To run the pipeline, simply run 'conduit'.`, pi.configFilePath())

return nil
}
Expand Down
9 changes: 7 additions & 2 deletions pkg/conduit/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,12 @@ type Config struct {
}

func DefaultConfig() Config {
return DefaultConfigWithBasePath(".")
dir, err := os.Getwd()
if err != nil {
panic(cerrors.Errorf("failed to get current directory: %w", err))
}

return DefaultConfigWithBasePath(dir)
}

func DefaultConfigWithBasePath(basePath string) Config {
Expand Down Expand Up @@ -273,7 +278,7 @@ func (c Config) Validate() error {
}
// check if folder exists
_, err = os.Stat(c.Pipelines.Path)
if c.Pipelines.Path != "pipelines" && os.IsNotExist(err) {
if c.Pipelines.Path != DefaultConfig().Pipelines.Path && os.IsNotExist(err) {
return invalidConfigFieldErr("pipelines.path")
}

Expand Down

0 comments on commit 55ebed9

Please sign in to comment.