From 1bffacd003bbc59c14631042dab9129d25863840 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 14 Oct 2023 17:31:34 +0200 Subject: [PATCH] Generalize getting project id --- local/platformsh/project.go | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/local/platformsh/project.go b/local/platformsh/project.go index b9440fdd..8bdf93c6 100644 --- a/local/platformsh/project.go +++ b/local/platformsh/project.go @@ -21,13 +21,12 @@ package platformsh import ( goerr "errors" - "fmt" "os" "path/filepath" "github.com/pkg/errors" + "github.com/rs/zerolog" "github.com/symfony-cli/symfony-cli/git" - "gopkg.in/yaml.v2" ) var ( @@ -96,21 +95,9 @@ func repositoryRootDir(currentDir string) string { } func getProjectID(projectRoot string, debug bool) string { - contents, err := os.ReadFile(filepath.Join(projectRoot, ".platform", "local", "project.yaml")) - if err != nil { - if debug { - fmt.Fprintf(os.Stderr, "WARNING: unable to find Platform.sh config file: %s\n", err) - } - return "" - } - var config struct { - ID string `yaml:"id"` - } - if err := yaml.Unmarshal(contents, &config); err != nil { - if debug { - fmt.Fprintf(os.Stderr, "ERROR: unable to decode Platform.sh config file: %s\n", err) - } + out, ok := psh.RunInteractive(zerolog.Nop(), projectRoot, []string{"project:info", "id"}, false, nil) + if !ok { return "" } - return config.ID + return out.String() }