Merge pull request #37 from polvi/ignore-failure

feat(ignore-failure): add ignore failure flag, fixes #36
This commit is contained in:
polvi 2014-03-18 20:50:00 -07:00
commit c2faaa503b

View File

@ -20,6 +20,9 @@ func main() {
var printVersion bool var printVersion bool
flag.BoolVar(&printVersion, "version", false, "Print the version and exit") flag.BoolVar(&printVersion, "version", false, "Print the version and exit")
var ignoreFailure bool
flag.BoolVar(&ignoreFailure, "ignore-failure", false, "Exits with 0 status in the event of malformed input from user-data")
var file string var file string
flag.StringVar(&file, "from-file", "", "Read user-data from provided file") flag.StringVar(&file, "from-file", "", "Read user-data from provided file")
@ -57,7 +60,12 @@ func main() {
log.Printf("Fetching user-data from datasource of type %q", ds.Type()) log.Printf("Fetching user-data from datasource of type %q", ds.Type())
userdata, err := ds.Fetch() userdata, err := ds.Fetch()
if err != nil { if err != nil {
log.Fatalf("Failed fetching user-data from datasource: %v", err) log.Printf("Failed fetching user-data from datasource: %v", err)
if ignoreFailure {
os.Exit(0)
} else {
os.Exit(1)
}
} }
if len(userdata) == 0 { if len(userdata) == 0 {
@ -67,7 +75,12 @@ func main() {
parsed, err := ParseUserData(userdata) parsed, err := ParseUserData(userdata)
if err != nil { if err != nil {
log.Fatalf("Failed parsing user-data: %v", err) log.Printf("Failed parsing user-data: %v", err)
if ignoreFailure {
os.Exit(0)
} else {
os.Exit(1)
}
} }
env := initialize.NewEnvironment("/", workspace) env := initialize.NewEnvironment("/", workspace)