-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
File error: open ./goss.yaml: no such file or directory #4
Comments
#7 adds the ability to specify the
So this kind of is enough for my use case. I'm still wondering why I have to define this twice and why I can upload multiple files but only run goss with a single file? |
Hi @michaelwittig: I ran into this same issue as well, its how goss operates though, so you can for example upload your tests over several yaml files inside a directory and then have an initial goss.yaml which calls in all of the other yaml files. Because as you mentioned the upload can upload an array of files - there is no set way of working out which yaml file is meant to be your master config file, hence why I added the goss_file key so that you can explicitly state what the master file is (the --gossfile flag to goss). I couldnt think up a better solution, you could in theory check the array if it contains only 1 value pass that through to the gossfile flag as well, but I thought this approach provides more control to you and allows for better control of the tests to goss. |
I like the solution you provided with the |
I agree -- I can work on this. Thanks for pointing this out @michaelwittig, and thanks for all of your updates @vamegh! |
Hi @fishnix no probs, thanks for merging it I appreciate it. Ive been thinking about this and think I have an easy solution.
This should do it - if its just a regular file and there is only 1 element in the array and gossfile hasnt been set then set the gossfile flag to call this file. this keeps everything working and auto-adds a single file to be the gossfile. |
I did this: diff --git a/packer-provisioner-goss.go b/packer-provisioner-goss.go
index 102a03f..b866775 100644
--- a/packer-provisioner-goss.go
+++ b/packer-provisioner-goss.go
@@ -39,9 +39,6 @@ type GossConfig struct {
// skip ssl check flag
SkipSSLChk bool `mapstructure:"skip_ssl"`
- // The --gossfile flag
- GossFile string `mapstructure:"goss_file"`
-
// The --vars flag
// Optional file containing variables, used within GOSS templating.
// Must be one of the files contained in the Tests array.
@@ -123,10 +120,6 @@ func (p *Provisioner) Prepare(raws ...interface{}) error {
p.config.Tests = make([]string, 0)
}
- if p.config.GossFile != "" {
- p.config.GossFile = fmt.Sprintf("--gossfile %s", p.config.GossFile)
- }
-
var errs *packer.MultiError
if p.config.Format != "" {
valid := false
@@ -216,9 +209,12 @@ func (p *Provisioner) Provision(ui packer.Ui, comm packer.Communicator) error {
}
}
- ui.Say("Running goss tests...")
- if err := p.runGoss(ui, comm); err != nil {
- return fmt.Errorf("Error running Goss: %s", err)
+ for _, file := range p.config.Tests {
+ file := filepath.Base(file)
+ ui.Say(fmt.Sprintf("Running goss tests (%s)...", file))
+ if err := p.runGoss(ui, comm, file); err != nil {
+ return fmt.Errorf("Error running Goss: %s", err)
+ }
}
return nil
@@ -255,11 +251,11 @@ func (p *Provisioner) installGoss(ui packer.Ui, comm packer.Communicator) error
}
// runGoss runs the Goss tests
-func (p *Provisioner) runGoss(ui packer.Ui, comm packer.Communicator) error {
+func (p *Provisioner) runGoss(ui packer.Ui, comm packer.Communicator, file string) error {
cmd := &packer.RemoteCmd{
Command: fmt.Sprintf(
- "cd %s && %s %s %s %s %s validate --retry-timeout %s --sleep %s %s",
- p.config.RemotePath, p.enableSudo(), p.config.DownloadPath, p.config.GossFile,
+ "cd %s && %s %s --gossfile %s %s %s validate --retry-timeout %s --sleep %s %s",
+ p.config.RemotePath, p.enableSudo(), p.config.DownloadPath, file,
p.vars(), p.debug(), p.retryTimeout(), p.sleep(), p.format(),
),
} this way it also supports multiple test suites... 🤔 |
closing old issues, reopen if still interested 👍 |
Hi,
I use the goss provisioner with the following config:
./packer.json
The goss yaml seems to be uploaded, but for some reason goss is started and falls back to the goss.yaml file.
packer output:
It seems to me (not familiar with go), that the
--gossfile
flag is never set, sogoss.yaml
is always assumed.The text was updated successfully, but these errors were encountered: