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

Support profiles not at root level of a git repository #2167

Closed
jayhendren opened this issue Sep 20, 2017 · 8 comments · Fixed by #4217
Closed

Support profiles not at root level of a git repository #2167

jayhendren opened this issue Sep 20, 2017 · 8 comments · Fixed by #4217
Labels
Aspect: UI-UX Component: Fetchers Parts that locate and obtain profiles.

Comments

@jayhendren
Copy link

jayhendren commented Sep 20, 2017

Please add the ability to specify a relative path when using the git fetcher such that InSpec can support using a profile in a repo where the repo is not at the root directory, such as a Chef cookbook used by Test Kitchen, or a repository that contains multiple profiles.

(The above is an updated description of this feature request. Below is the original description.)


This was discussed briefly in inspec/kitchen-inspec#66 and determined to be a new issue.

When including a profile from an inspec.yml file, InSpec expects the included profile to live in top-level directories in the referenced git repository/tarball/path.

When writing a profile to be used with TestKitchen, specifically with kitchen-inspec, the profile must live in a subdirectory called test/integration/$suite/inspec.

Because of this discrepancy, it's impossible to write a profile that can be run with TestKitchen and also exported for use by other profiles.

@adamleff
Copy link
Contributor

@Poohblah the profile must be in test/integration/$suite/inspec only if you wish to accept the default paths. You can choose to not use that at all and instead set the inspec_tests config parameter in the verifier section (either globally, or per-suite).

The recommended practice is to place your profiles in separate git repos, and they can either inherit from each other, or they may each be listed in the inspec_tests section when using kitchen-inspec.

Therefore, I'm afraid I'm not clear on what the exact issue is. Can you please be more specific?

@jayhendren
Copy link
Author

So the desire here is: as a cookbook author, I want to write cookbooks with integration tests, and as a consumer of those cookbooks, I want to be able to consume their tests.

You can choose to not use that at all and instead set the inspec_tests config parameter in the verifier section (either globally, or per-suite).

Yes, but then if I put my profile in the top-level directory of my cookbook so that I may export my profile, the libraries directory conflicts with Chef (since libraries/*.rb files are evaluated by both Chef and InSpec).

The recommended practice is to place your profiles in separate git repos, and they can either inherit from each other, or they may each be listed in the inspec_tests section when using kitchen-inspec.

Technically that works, but I'd really prefer not to have my tests divorced from the things they are testing. By default, ChefSpec/ServerSpec/InSpec tests live in the same cookbook repository as the cookbook they are testing, which I think is best behavior.

@adamleff
Copy link
Contributor

OK, so let me try to understand the real issue here as I feel we've conflated your particular use case with how InSpec works vs. how Test Kitchen works...

In Cookbook A, stored in its own git repo, you have a test/integration/$suite/inspec directory that contains an InSpec profile.

In Cookbook B, you wish to consume the profile from test/integration/$suite/inspec from Cookbook A. However, InSpec doesn't support profiles that aren't at the top-level of the repository, so you are unable to do so.

Did I accurately sum up your particular use case?

@jayhendren
Copy link
Author

That is an accurate summation! :)

@adamleff
Copy link
Contributor

Phew! OK. So I think what we need to do is turn this issue into a feature request that looks like this:

Title: Support profiles not at root level of a git repository

Please add the ability to specify a relative path when using the git fetcher such that InSpec can support using a profile in a repo where the repo is not at the root directory, such as a Chef cookbook used by Test Kitchen, or a repository that contains multiple profiles.

How does that sound? If that sounds good, would you please modify the issue accordingly? I'm happy to do so as well but would like us to agree on what you're looking for.

@jayhendren
Copy link
Author

Updated. Thanks for taking the time to make sure we were both on the same page!

@jayhendren jayhendren changed the title Profiles cannot be both exported and used by TestKitchen Support profiles not at root level of a git repository Sep 20, 2017
@jerryaldrichiii jerryaldrichiii self-assigned this Oct 16, 2018
@jerryaldrichiii jerryaldrichiii added Type: Feature Request Component: Loader Loading and Evaling profiles and libraries. labels Oct 16, 2018
@jerryaldrichiii
Copy link
Contributor

This should be closed if the above PR gets merged, given this I'm going to remove the assignment to me.

@jerryaldrichiii jerryaldrichiii removed their assignment Feb 20, 2019
@clintoncwolfe clintoncwolfe added Status: Duplicate Component: Fetchers Parts that locate and obtain profiles. and removed Component: Loader Loading and Evaling profiles and libraries. labels Feb 21, 2019
@clintoncwolfe
Copy link
Contributor

This is a duplicate of #1974

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Aspect: UI-UX Component: Fetchers Parts that locate and obtain profiles.
Projects
None yet
5 participants