tideliftcli/tidelift_yml.go

55 lines
869 B
Go
Raw Normal View History

2019-05-15 02:40:51 +00:00
package main
import (
2019-05-15 03:19:10 +00:00
"io/ioutil"
2019-05-15 02:40:51 +00:00
"os"
2019-05-15 03:19:10 +00:00
"path/filepath"
"gopkg.in/yaml.v2"
2019-05-15 02:40:51 +00:00
)
func verifyTideliftYamlExists(directory string) bool {
os.Chdir(directory)
if _, err := os.Stat(".tidelift.yml"); err == nil {
return true
}
return false
}
2019-05-15 03:19:10 +00:00
func passesMinimumRequirements(directory string) string {
os.Chdir(directory)
filename, _ := filepath.Abs("./.tidelift.yml")
yamlFile, err := ioutil.ReadFile(filename)
check(err)
type TideliftYML struct {
TeamName string `yaml:"team-name"`
RepositoryName string `yaml:"repository-name"`
}
var yml TideliftYML
err = yaml.Unmarshal(yamlFile, &yml)
check(err)
// Check for Team name
if len(yml.TeamName) <= 0 {
return "team-name"
}
// Check for Repository Name
if len(yml.RepositoryName) <= 0 {
return "repository-name"
}
return ""
}
func check(e error) {
if e != nil {
panic(e)
}
}