summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/chef/provider/apt_repository.rb22
1 files changed, 15 insertions, 7 deletions
diff --git a/lib/chef/provider/apt_repository.rb b/lib/chef/provider/apt_repository.rb
index af4ed10d07..40a9761a52 100644
--- a/lib/chef/provider/apt_repository.rb
+++ b/lib/chef/provider/apt_repository.rb
@@ -58,16 +58,10 @@ class Chef
action :nothing
end
- components = if is_ppa_url?(new_resource.uri) && new_resource.components.empty?
- "main"
- else
- new_resource.components
- end
-
repo = build_repo(
new_resource.uri,
new_resource.distribution,
- components,
+ repo_components,
new_resource.trusted,
new_resource.arch,
new_resource.deb_src
@@ -252,6 +246,20 @@ class Chef
url.start_with?("ppa:")
end
+ # determine the repository's components:
+ # - "components" property if defined
+ # - "main" if "components" not defined and the repo is a PPA URL
+ # - otherwise nothing
+ #
+ # @return [String] the repository component
+ def repo_components
+ if is_ppa_url?(new_resource.uri) && new_resource.components.empty?
+ "main"
+ else
+ new_resource.components
+ end
+ end
+
def make_ppa_url(ppa)
return unless is_ppa_url?(ppa)
owner, repo = ppa[4..-1].split("/")