goss-org / goss

Quick and Easy server testing/validation
https://goss.rocks
Apache License 2.0
5.57k stars 472 forks source link

Allow users to overwrite default driver/type #539

Open aelsabbahy opened 4 years ago

aelsabbahy commented 4 years ago

Describe the feature:

Currently goss decides which package manager and service manager to use based on your OS. This feature is to allow users to overwrite this.

Describe the solution you'd like

Open to suggestions on this, two possibilities I'm debating: 1) Use PKG_TYPE:PACKAGE_NAME syntax, this is consistent with the port checks.

Example:

package:
  rpm:coreutils:
    installed: true
    versions:
    - "8.27"

2) Create a new attribute to control this, example "type" or "'driver"

Example:

package:
  coreutils:
    type: rpm
    installed: true
    versions:
    - "8.27"
directionless commented 4 years ago

Either seems fine. The attribute model feels slightly cleaner in go structs.

What happens if you want coreutils in both a deb and an rpm installed?

pedroMMM commented 4 years ago

@aelsabbahy the 2nd option is cleaner for everyone, honestly I am not even a fan that the port checks use it.

I would also take it a step forwarder and allow the user to pass custom paths for the type binaries.

What happens if you want coreutils in both a deb and an rpm installed?

@directionless that is a weird setup but having 2 tests should just suffice.

aelsabbahy commented 4 years ago

The attribute model does seem cleaner, but doesn't handle collisions or duplicates.

Another option is the ability to overwrite the key attribute, there's already work that's been done on this and new work is scheduled:

@directionless that is a weird setup but having 2 tests should just suffice.

I'm not a fan of forcing two tests.. Feels very limiting.

Another example of a resource that might benefit from this is the http one. GET vs PUT same URL.

Hopefully, we can come up with a consistent/flexible consensus on this and normalize everything in goss for it.

pedroMMM commented 4 years ago

The attribute model does seem cleaner, but doesn't handle collisions or duplicates.

Another option is the ability to overwrite the key attribute, there's already work that's been done on this and new work is scheduled:

  • 431 - command/exec

  • 518 - dns/hostname

Oh yeah, I had forgotten about that! This a great feature even if newbies can get confused the first time they see it.

@directionless that is a weird setup but having 2 tests should just suffice.

I'm not a fan of forcing two tests.. Feels very limiting.

Another example of a resource that might benefit from this is the http one. GET vs PUT same URL.

Hopefully, we can come up with a consistent/flexible consensus on this and normalize everything in goss for it.

That is fair, introducing 2 tests should be avoided but that particular use case seems on the outside of the 80% of the use cases Goss aims for.

That said we could introduce a type and types attributes, they would be mutually exclusive and the plural version would just take in an array. This leaves a bit more work on the actual struct and code but leaves the API clean and intuitive. While is particular implementation might be skipped, we could still use this pattern in other places.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

aelsabbahy commented 4 years ago

This is still being discussed, not stale

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

aelsabbahy commented 3 years ago

Going to just mark the 2nd approach as the approved one for now.

I'll work my way towards it a resource at a time, and will accept PRs that move the code in that direction. If anyone thinks it's a bad idea.. feel free to chime in here.