Skip to content

Commit

Permalink
make Normalize a public function for third-party usage
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas De Loof <[email protected]>
  • Loading branch information
ndeloof committed Feb 16, 2023
1 parent eeb4020 commit 3c7d0d9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion loader/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions loader/normalize.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions loader/normalize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 3c7d0d9

Please sign in to comment.