From 0a8a83d882d21a26a35a747ca0b7604e00dda26e Mon Sep 17 00:00:00 2001 From: Alec Thomas Date: Fri, 7 Jun 2024 12:37:26 +1000 Subject: [PATCH] fix: fixes for behaviour regressions - 46b7c972d567c6e289e3f0aa792f38d3878f82c7. was writing absolute paths into `ftl-project.toml` - `ftl config/secret get` were not writing raw JSON values --- cmd/ftl/cmd_config.go | 11 +++-------- cmd/ftl/cmd_secret.go | 7 +------ common/projectconfig/projectconfig.go | 15 --------------- common/projectconfig/projectconfig_test.go | 4 ++-- 4 files changed, 6 insertions(+), 31 deletions(-) diff --git a/cmd/ftl/cmd_config.go b/cmd/ftl/cmd_config.go index f43901936e..59a9ee4272 100644 --- a/cmd/ftl/cmd_config.go +++ b/cmd/ftl/cmd_config.go @@ -9,10 +9,11 @@ import ( "connectrpc.com/connect" + "github.com/alecthomas/types/optional" + "github.com/TBD54566975/ftl/backend/controller/admin" ftlv1 "github.com/TBD54566975/ftl/backend/protos/xyz/block/ftl/v1" cf "github.com/TBD54566975/ftl/common/configuration" - "github.com/alecthomas/types/optional" ) type configCmd struct { @@ -91,13 +92,7 @@ func (s *configGetCmd) Run(ctx context.Context, adminClient admin.Client) error if err != nil { return err } - - var value any - err = json.Unmarshal(resp.Msg.Value, &value) - if err != nil { - return fmt.Errorf("%s: %w", s.Ref, err) - } - fmt.Println(value) + fmt.Printf("%s\n", resp.Msg.Value) return nil } diff --git a/cmd/ftl/cmd_secret.go b/cmd/ftl/cmd_secret.go index e185bccb57..a2ffa1dc70 100644 --- a/cmd/ftl/cmd_secret.go +++ b/cmd/ftl/cmd_secret.go @@ -94,12 +94,7 @@ func (s *secretGetCmd) Run(ctx context.Context, adminClient admin.Client) error if err != nil { return err } - - var value any - if err := json.Unmarshal(resp.Msg.Value, &value); err != nil { - return fmt.Errorf("%s: %w", s.Ref, err) - } - fmt.Println(value) + fmt.Printf("%s\n", resp.Msg.Value) return nil } diff --git a/common/projectconfig/projectconfig.go b/common/projectconfig/projectconfig.go index dc393e9cfc..dfa65c3b19 100644 --- a/common/projectconfig/projectconfig.go +++ b/common/projectconfig/projectconfig.go @@ -136,21 +136,6 @@ func loadFile(path string) (Config, error) { } return Config{}, fmt.Errorf("unknown configuration keys: %s", strings.Join(keys, ", ")) } - - // make modules-dir absolute to mimic the behavior of the CLI - for i, dir := range config.ModuleDirs { - if !filepath.IsAbs(dir) { - config.ModuleDirs[i] = filepath.Join(filepath.Dir(path), dir) - } - } - - // make external-dirs absolute to mimic the behavior of the CLI - for i, dir := range config.ExternalDirs { - if !filepath.IsAbs(dir) { - config.ExternalDirs[i] = filepath.Join(filepath.Dir(path), dir) - } - } - return config, nil } diff --git a/common/projectconfig/projectconfig_test.go b/common/projectconfig/projectconfig_test.go index f44ca5e87f..c9fb9fdfe2 100644 --- a/common/projectconfig/projectconfig_test.go +++ b/common/projectconfig/projectconfig_test.go @@ -25,8 +25,8 @@ func TestProjectConfig(t *testing.T) { }, }, }, - ModuleDirs: []string{"testdata/a/b/c", "testdata/d"}, - ExternalDirs: []string{"testdata/e/f", "testdata/g/h"}, + ModuleDirs: []string{"a/b/c", "d"}, + ExternalDirs: []string{"e/f", "g/h"}, Commands: Commands{ Startup: []string{"echo 'Executing global pre-build command'"}, },