mirror of
https://github.com/inspec/inspec
synced 2024-11-10 07:04:15 +00:00
Rename path_within_repo option to relative_path
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
This commit is contained in:
parent
f1a892c857
commit
0e32d2429f
3 changed files with 13 additions and 12 deletions
|
@ -212,7 +212,7 @@ depends:
|
|||
|
||||
### git
|
||||
|
||||
A `git` setting specifies a profile that is located in a git repository, with optional settings for branch, tag, commit, version, and profile_path. The source location is translated into a URL upon resolution. This type of dependency supports version constraints via semantic versioning as git tags.
|
||||
A `git` setting specifies a profile that is located in a git repository, with optional settings for branch, tag, commit, version, and relative_path. The source location is translated into a URL upon resolution. This type of dependency supports version constraints via semantic versioning as git tags.
|
||||
|
||||
```YAML
|
||||
depends:
|
||||
|
@ -222,7 +222,7 @@ depends:
|
|||
tag: desired_version
|
||||
commit: pinned_commit
|
||||
version: semver_via_tags
|
||||
path_within_repo: relative/optional/path/to/profile
|
||||
relative_path: relative/optional/path/to/profile
|
||||
```
|
||||
|
||||
### supermarket
|
||||
|
|
|
@ -37,12 +37,12 @@ module Fetchers
|
|||
|
||||
def initialize(remote_url, opts = {})
|
||||
@branch = opts[:branch]
|
||||
@profile_directory = nil
|
||||
@tag = opts[:tag]
|
||||
@ref = opts[:ref]
|
||||
@remote_url = remote_url
|
||||
@repo_directory = nil
|
||||
@path_within_repo = opts[:path_within_repo]
|
||||
@profile_directory = nil # TODO remove this if possible, distinction without a difference
|
||||
@relative_path = opts[:relative_path]
|
||||
end
|
||||
|
||||
def fetch(dir)
|
||||
|
@ -51,14 +51,15 @@ module Fetchers
|
|||
|
||||
if cloned?
|
||||
checkout
|
||||
# TODO - verify this still works with relative path
|
||||
else
|
||||
Dir.mktmpdir do |tmpdir|
|
||||
checkout(tmpdir)
|
||||
if @path_within_repo
|
||||
if @relative_path
|
||||
@profile_directory = dir
|
||||
Inspec::Log.debug("Checkout of #{resolved_ref} successful. " \
|
||||
"Moving #{@path_within_repo} to #{dir}")
|
||||
target_profile = File.join(tmpdir, @path_within_repo)
|
||||
"Moving #{@relative_path} to #{dir}")
|
||||
target_profile = File.join(tmpdir, @relative_path)
|
||||
FileUtils.cp_r(target_profile, dir)
|
||||
else
|
||||
Inspec::Log.debug("Checkout of #{resolved_ref} successful. " \
|
||||
|
@ -71,8 +72,8 @@ module Fetchers
|
|||
end
|
||||
|
||||
def cache_key
|
||||
return resolved_ref unless @path_within_repo
|
||||
OpenSSL::Digest::SHA256.hexdigest(resolved_ref + @path_within_repo)
|
||||
return resolved_ref unless @relative_path
|
||||
OpenSSL::Digest::SHA256.hexdigest(resolved_ref + @relative_path)
|
||||
end
|
||||
|
||||
def archive_path
|
||||
|
@ -81,7 +82,7 @@ module Fetchers
|
|||
|
||||
def resolved_source
|
||||
source = { git: @remote_url, ref: resolved_ref }
|
||||
source[:path_within_repo] = @path_within_repo if @path_within_repo
|
||||
source[:relative_path] = @relative_path if @relative_path
|
||||
source
|
||||
end
|
||||
|
||||
|
|
|
@ -33,12 +33,12 @@ describe "profiles with git-based dependencies" do
|
|||
{
|
||||
'name' => 'deep-git-dep',
|
||||
'git' => @deep_git_dep_dir,
|
||||
'path_within_repo' => 'profiles/deep-profile'
|
||||
'relative_path' => 'profiles/deep-profile'
|
||||
},
|
||||
{
|
||||
'name' => 'another-deep-git-dep',
|
||||
'git' => @deep_git_dep_dir,
|
||||
'path_within_repo' => 'profiles/another-deep-profile'
|
||||
'relative_path' => 'profiles/another-deep-profile'
|
||||
}
|
||||
]
|
||||
File.write(File.join(@profile_dir, 'inspec.yml'), YAML.dump(inspec_yml))
|
||||
|
|
Loading…
Reference in a new issue