From 3c7d0d9792e55316a98fcaab857d5d25eeadd003 Mon Sep 17 00:00:00 2001 From: Nicolas De Loof Date: Thu, 16 Feb 2023 10:47:59 +0100 Subject: [PATCH] make Normalize a public function for third-party usage Signed-off-by: Nicolas De Loof --- loader/loader.go | 2 +- loader/normalize.go | 4 ++-- loader/normalize_test.go | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/loader/loader.go b/loader/loader.go index d8ff2ef0f..93b3c93c2 100644 --- a/loader/loader.go +++ b/loader/loader.go @@ -233,7 +233,7 @@ func Load(configDetails types.ConfigDetails, options ...func(*Options)) (*types. } if !opts.SkipNormalization { - err = normalize(project, opts.ResolvePaths) + err = Normalize(project, opts.ResolvePaths) if err != nil { return nil, err } diff --git a/loader/normalize.go b/loader/normalize.go index 86d3f4e50..9153b56f4 100644 --- a/loader/normalize.go +++ b/loader/normalize.go @@ -28,8 +28,8 @@ import ( "github.com/sirupsen/logrus" ) -// normalize compose project by moving deprecated attributes to their canonical position and injecting implicit defaults -func normalize(project *types.Project, resolvePaths bool) error { +// Normalize compose project by moving deprecated attributes to their canonical position and injecting implicit defaults +func Normalize(project *types.Project, resolvePaths bool) error { absWorkingDir, err := filepath.Abs(project.WorkingDir) if err != nil { return err diff --git a/loader/normalize_test.go b/loader/normalize_test.go index 5837858b3..93e8e7129 100644 --- a/loader/normalize_test.go +++ b/loader/normalize_test.go @@ -82,7 +82,7 @@ networks: mynet: name: myProject_mynet ` - err := normalize(&project, false) + err := Normalize(&project, false) assert.NilError(t, err) marshal, err := yaml.Marshal(project) assert.NilError(t, err) @@ -118,7 +118,7 @@ networks: default: name: myProject_default `, filepath.Join(wd, "testdata")) - err := normalize(&project, true) + err := Normalize(&project, true) assert.NilError(t, err) marshal, err := yaml.Marshal(project) assert.NilError(t, err) @@ -142,7 +142,7 @@ func TestNormalizeAbsolutePaths(t *testing.T) { WorkingDir: absWorkingDir, ComposeFiles: []string{absComposeFile, absOverrideFile}, } - err := normalize(&project, false) + err := Normalize(&project, false) assert.NilError(t, err) assert.DeepEqual(t, expected, project) } @@ -180,7 +180,7 @@ func TestNormalizeVolumes(t *testing.T) { WorkingDir: absCwd, ComposeFiles: []string{}, } - err := normalize(&project, false) + err := Normalize(&project, false) assert.NilError(t, err) assert.DeepEqual(t, expected, project) } @@ -236,7 +236,7 @@ networks: default: name: myProject_default ` - err := normalize(&project, true) + err := Normalize(&project, true) assert.NilError(t, err) marshal, err := yaml.Marshal(project) assert.NilError(t, err)