Closed retr0h closed 3 months ago
You can use goss as a package:
var out bytes.Buffer
opts := []gossutil.ConfigOption{
gossutil.WithMaxConcurrency(1),
gossutil.WithResultWriter(&out),
gossutil.WithSpecFile(w.properties.Gossfile),
}
cfg, err := gossutil.NewConfig(opts...)
if err != nil {
return err
}
_, err = goss.Validate(cfg)
if err != nil {
return err
}
res := &outputs.StructuredOutput{}
err = json.Unmarshal(out.Bytes(), res)
if err != nil {
return err
}
if res.Summary.Failed > 0 {
return fmt.Errorf("check failed: %v", res.SummaryLine, pd)
}
return nil
Thanks @ripienaar
I did not see much information about this, but I want to use the goss package in another project I'm working on, basically I am writing the reverse of Goss (i.e.
goss up
).I can embed the CLI into my project using ember, but I'd prefer not to do this. As the CLI seems to be the gateway into Goss, I wanted to know if this was a supported use case.