Skip to content

Commit

Permalink
Code changes
Browse files Browse the repository at this point in the history
  • Loading branch information
janpreet committed Jul 30, 2024
1 parent 688acfb commit 28776ba
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/janpreet/kado/packages/opa"
"github.com/janpreet/kado/packages/render"
"github.com/janpreet/kado/packages/terraform"
"github.com/janpreet/kado/packages/terragrunt" // Import the new package
"github.com/janpreet/kado/packages/terragrunt"
)

func convertYAMLToSlice(yamlData map[string]interface{}) []map[string]interface{} {
Expand Down
8 changes: 4 additions & 4 deletions packages/engine/formatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"strings"
)

// FormatKDFile formats a single .kd file with proper indentation and without extra newlines at the end.

func FormatKDFile(filePath string) error {
file, err := os.Open(filePath)
if err != nil {
Expand Down Expand Up @@ -45,7 +45,7 @@ func FormatKDFile(filePath string) error {
buffer.WriteString(" " + trimmedLine + "\n")
} else {
if commentRegex.MatchString(trimmedLine) {
// Remove extra spaces in comments

trimmedLine = strings.TrimSpace(trimmedLine)
trimmedLine = strings.Replace(trimmedLine, "#", "#", 1)
}
Expand All @@ -64,7 +64,7 @@ func FormatKDFile(filePath string) error {
formattedLines = append(formattedLines, buffer.String())
}

// Remove the last newline if it exists

if len(formattedLines) > 0 && formattedLines[len(formattedLines)-1] == "\n" {
formattedLines = formattedLines[:len(formattedLines)-1]
}
Expand All @@ -79,7 +79,7 @@ func FormatKDFile(filePath string) error {
return nil
}

// FormatKDFilesInDir formats all .kd files in a given directory with proper indentation and without extra newlines at the end.

func FormatKDFilesInDir(dir string) error {
return filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {
if err != nil {
Expand Down

0 comments on commit 28776ba

Please sign in to comment.