Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do it only on selected files
Browse files Browse the repository at this point in the history
jsoriano committed Oct 16, 2023

Unverified

The committer email address is not verified.
1 parent 4104706 commit 9c82db6
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions internal/formatter/formatter.go
Original file line number Diff line number Diff line change
@@ -8,7 +8,6 @@ import (
"fmt"
"os"
"path/filepath"
"strings"

"github.com/Masterminds/semver/v3"

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

defaultActionOnKeysWithDot := KeysWithDotActionNested
if specVersion.LessThan(semver.MustParse("3.0.0")) {
defaultActionOnKeysWithDot = KeysWithDotActionNone
}
err = filepath.Walk(packageRoot, func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}

options := formatterOptions{
specVersion: *specVersion,
extension: filepath.Ext(info.Name()),
preferedKeysWithDotAction: defaultActionOnKeysWithDot,
failFast: failFast,
specVersion: *specVersion,
extension: filepath.Ext(info.Name()),
failFast: failFast,
}

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

if filepath.Base(filepath.Dir(filepath.Dir(path))) == "transform" && info.Name() == "transform.yml" {
options.preferedKeysWithDotAction = KeysWithDotActionNone
}
if strings.HasPrefix(info.Name(), "test-") && strings.HasSuffix(info.Name(), "-config.yml") {
options.preferedKeysWithDotAction = KeysWithDotActionQuote
// Configure handling of keys with dots.
if !specVersion.LessThan(semver.MustParse("3.0.0")) {
if info.Name() == "manifest.yml" {
options.preferedKeysWithDotAction = KeysWithDotActionNested
}
}

err = formatFile(path, options)

0 comments on commit 9c82db6

Please sign in to comment.