Skip to content

Commit 9c82db6

Browse files
committed
Do it only on selected files
1 parent 4104706 commit 9c82db6

1 file changed

Lines changed: 8 additions & 14 deletions

File tree

internal/formatter/formatter.go

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"fmt"
99
"os"
1010
"path/filepath"
11-
"strings"
1211

1312
"github.com/Masterminds/semver/v3"
1413

@@ -53,20 +52,15 @@ func Format(packageRoot string, failFast bool) error {
5352
return fmt.Errorf("failed to parse package format version %q: %w", manifest.SpecVersion, err)
5453
}
5554

56-
defaultActionOnKeysWithDot := KeysWithDotActionNested
57-
if specVersion.LessThan(semver.MustParse("3.0.0")) {
58-
defaultActionOnKeysWithDot = KeysWithDotActionNone
59-
}
6055
err = filepath.Walk(packageRoot, func(path string, info os.FileInfo, err error) error {
6156
if err != nil {
6257
return err
6358
}
6459

6560
options := formatterOptions{
66-
specVersion: *specVersion,
67-
extension: filepath.Ext(info.Name()),
68-
preferedKeysWithDotAction: defaultActionOnKeysWithDot,
69-
failFast: failFast,
61+
specVersion: *specVersion,
62+
extension: filepath.Ext(info.Name()),
63+
failFast: failFast,
7064
}
7165

7266
if info.IsDir() && info.Name() == "ingest_pipeline" {
@@ -76,11 +70,11 @@ func Format(packageRoot string, failFast bool) error {
7670
return nil
7771
}
7872

79-
if filepath.Base(filepath.Dir(filepath.Dir(path))) == "transform" && info.Name() == "transform.yml" {
80-
options.preferedKeysWithDotAction = KeysWithDotActionNone
81-
}
82-
if strings.HasPrefix(info.Name(), "test-") && strings.HasSuffix(info.Name(), "-config.yml") {
83-
options.preferedKeysWithDotAction = KeysWithDotActionQuote
73+
// Configure handling of keys with dots.
74+
if !specVersion.LessThan(semver.MustParse("3.0.0")) {
75+
if info.Name() == "manifest.yml" {
76+
options.preferedKeysWithDotAction = KeysWithDotActionNested
77+
}
8478
}
8579

8680
err = formatFile(path, options)

0 commit comments

Comments
 (0)