From 55ebed9182c340daf63e494daf10101331cb569a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Haris=20Osmanagi=C4=87?= Date: Fri, 8 Nov 2024 16:13:11 +0100 Subject: [PATCH] Load configs and directories from the working directory (#1952) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Load configuration and needed directories from the working directory * update check --------- Co-authored-by: Raúl Barroso --- cmd/cli/pipelines_init.go | 5 +---- pkg/conduit/config.go | 9 +++++++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/cmd/cli/pipelines_init.go b/cmd/cli/pipelines_init.go index 2094b162f..8b27c420b 100644 --- a/cmd/cli/pipelines_init.go +++ b/cmd/cli/pipelines_init.go @@ -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 } diff --git a/pkg/conduit/config.go b/pkg/conduit/config.go index 0f9e3639e..aba89f144 100644 --- a/pkg/conduit/config.go +++ b/pkg/conduit/config.go @@ -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 { @@ -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") }