Skip to content

Commit cb12939

Browse files
authored
Prevent writing of different list files with same content in debian (#761)
1 parent 252589b commit cb12939

File tree

2 files changed

+10
-18
lines changed

2 files changed

+10
-18
lines changed

recipes/repository.rb

+9-11
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
# A2923DFF56EDA6E76E55E492D3A80E30382E94DE expires in 2022
3030
# D75CEA17048B9ACBF186794B32637D44F14F620E expires in 2032
31-
apt_gpg_keys = ['A2923DFF56EDA6E76E55E492D3A80E30382E94DE', 'D75CEA17048B9ACBF186794B32637D44F14F620E']
31+
apt_gpg_key = 'A2923DFF56EDA6E76E55E492D3A80E30382E94DE'
3232

3333
# DATADOG_RPM_KEY_E09422B3.public expires in 2022
3434
# DATADOG_RPM_KEY_20200908.public expires in 2024
@@ -65,16 +65,14 @@
6565
retries = node['datadog']['aptrepo_retries']
6666
keyserver = node['datadog']['aptrepo_use_backup_keyserver'] ? node['datadog']['aptrepo_backup_keyserver'] : node['datadog']['aptrepo_keyserver']
6767
# Add APT repositories
68-
apt_gpg_keys.each do |apt_gpg_key|
69-
apt_repository "datadog_apt_#{apt_gpg_key}" do
70-
keyserver keyserver
71-
key apt_gpg_key
72-
uri node['datadog']['aptrepo']
73-
distribution node['datadog']['aptrepo_dist']
74-
components components
75-
action :add
76-
retries retries
77-
end
68+
apt_repository 'datadog' do
69+
keyserver keyserver
70+
key apt_gpg_key
71+
uri node['datadog']['aptrepo']
72+
distribution node['datadog']['aptrepo_dist']
73+
components components
74+
action :add
75+
retries retries
7876
end
7977

8078
# Previous versions of the cookbook could create this repo file, make sure we remove it now

spec/repository_spec.rb

+1-7
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,11 @@
1515
end
1616

1717
it 'sets up an apt repo with fingerprint A2923DFF56EDA6E76E55E492D3A80E30382E94DE' do
18-
expect(chef_run).to add_apt_repository('datadog_apt_A2923DFF56EDA6E76E55E492D3A80E30382E94DE').with(
18+
expect(chef_run).to add_apt_repository('datadog').with(
1919
key: ['A2923DFF56EDA6E76E55E492D3A80E30382E94DE']
2020
)
2121
end
2222

23-
it 'sets up an apt repo with fingerprint D75CEA17048B9ACBF186794B32637D44F14F620E' do
24-
expect(chef_run).to add_apt_repository('datadog_apt_D75CEA17048B9ACBF186794B32637D44F14F620E').with(
25-
key: ['D75CEA17048B9ACBF186794B32637D44F14F620E']
26-
)
27-
end
28-
2923
it 'removes the datadog-beta repo' do
3024
expect(chef_run).to remove_apt_repository('datadog-beta')
3125
end

0 commit comments

Comments
 (0)