Skip to content
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

usage as a library #544

Closed
ripienaar opened this issue Feb 8, 2020 · 10 comments
Closed

usage as a library #544

ripienaar opened this issue Feb 8, 2020 · 10 comments

Comments

@ripienaar
Copy link
Collaborator

ripienaar commented Feb 8, 2020

Describe the feature:

I would like to be able to use goss as a package from within other go applications, there are various infra automation scenarios where its desirable to deliver the system as a single binary.

I'd like to do an integration into choria.io and some other things

Describe the solution you'd like

At least I would like to be able to do a validate, a few of the functions in validate.go, store.go, template.go and a few others do os.Exit() and require a number of unexported functions.

Would you be open to adjusting things a bit so a external package can use goss as a package for at least doing Validate?

Similar to #112

I'd roughly keep things are, even accepting a cli context in validate but I'd add a few helpers to let me do:

err = goss.ValidateWithOptions(goss.GossFile(...), goss.VarsFile(...), goss.OutputFormat(goss.JSON))

additional options for pkg type, output format and options, color, duration, retry duration and max concurrency

Describe alternatives you've considered

I tried to write this from the outside - alas, the os.Exit() etc is a pain

@pedroMMM
Copy link
Contributor

pedroMMM commented Feb 9, 2020

This is a reasonable request and to be honest, I am not a fan of using os.Exit() and cli.Context outside of the CLI functions.

additional options for pkg type, output format and options, color, duration, retry duration and max concurrency

This is confusing, could you go into more detail of your use case, please?

My only worry is that @aelsabbahy will not prioritize this highly. Then you could work on this and I would love to help out.

@ripienaar
Copy link
Collaborator Author

This is a reasonable request and to be honest, I am not a fan of using os.Exit() and cli.Context outside of the CLI functions.

additional options for pkg type, output format and options, color, duration, retry duration and max concurrency

This is confusing, could you go into more detail of your use case, please?

simply they are the other options the package today get from the CLI - I will give equivelant in code.

@aelsabbahy
Copy link
Member

Marking this as approved. It's very much an improvement to the current code. I probably won't dedicated personal time to this due to other issues being higher priority for me. That said, I will gladly review and merge changes that introduce this with testing.

Honestly, the parts of the code that will benefit most from this refactor are the parts that would benefit most from having proper go based tests in place.

@aelsabbahy
Copy link
Member

This is a reasonable request and to be honest, I am not a fan of using os.Exit() and cli.Context outside of the CLI functions.

6b7und8rs1v21

In all seriousness, there's so much of the codebase that I've wanted to rewrite. My time has been limited and I end up favoring bug fixes and features to codequality improvements.

I'm a huge fan of this ticket.

@ripienaar
Copy link
Collaborator Author

I am also quite busy so my effort will be to get this done with as little as possible to reach my needs. Hopefully others can pick up where I left off.

@ripienaar
Copy link
Collaborator Author

ripienaar commented Feb 12, 2020

Work being done:

@aelsabbahy
Copy link
Member

@ripienaar Is this done at this point?

Also, what was your use-case, curious on where goss is being used as a library =)

@ripienaar
Copy link
Collaborator Author

Yup done thanks.

I make choria.io, my use case is to make a very large scale dgoss like thing and some other stuff

Choria will have a new monitoring related distribution and could run goss checks regularly and handle distribution of the check definitions etc

And things like adhic checks etc. It’s a orchestration system known to be deployed on fleets with 6 to 7 number node counts

@aelsabbahy
Copy link
Member

Awesome, thanks!

I'll read up on choria, sounds like an interesting project =)

@ripienaar
Copy link
Collaborator Author

ripienaar commented Jul 17, 2020

$ choria req scout goss_validate file=/etc/choria/goss.yaml
....
Summary of Failed Tests:

   0: 27

Summary of Success:

   5: 27

Summary of Tests:

   5: 27

Finished processing 27 / 27 hosts in 3.279081845s

It sends back the reports etc, summaries show that all 27 machines was sucesful, ran 5 tests had no failures.

So 3 seconds is kind of slow - but these machines are in europe, us and uk. On a lan with fast networks 27 000 machines would take the same time :P

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants