Skip to content

Commit

Permalink
feat: abs path
Browse files Browse the repository at this point in the history
  • Loading branch information
0daryo committed Dec 18, 2019
1 parent a6f527f commit 282b238
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
File renamed without changes.
29 changes: 22 additions & 7 deletions src/yaml.go
Expand Up @@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"io/ioutil"
"log"
"os"
"path/filepath"

Expand Down Expand Up @@ -59,17 +60,31 @@ func fileExists(filename string) bool {
return !info.IsDir()
}

func find(file string) (string, error) {
files := []string{file}
for _, file := range files {
_, err := os.Stat(file)
if err == nil {
return file, nil
}
}
return "", errors.New("config for tfnotify is not found at all")
}

func Lint() error {
var buf []byte
var err error
if fileExists("kustomize-lint.yaml") {
buf, err = ioutil.ReadFile("./kustomize-lint.yaml")
p, err := filepath.Abs("./kustomize-lint.yaml")
if err != nil {
log.Fatal(err)
}
buf, err = ioutil.ReadFile(p)
if err != nil {
fmt.Println(err)
return err
}
} else {
buf, err = ioutil.ReadFile("./kustomize-lint-ex.yaml")
}
if err != nil {
fmt.Println(err)
return err
log.Fatal(errors.New("kustomize-lint.yaml is not set"))
}

conf, err := ReadOnConfig(buf)
Expand Down

0 comments on commit 282b238

Please sign in to comment.