Skip to content

Commit 081c1ce

Browse files
committed
(CAT-2378) Rubocop issue fixed - EnforcedStyle, ClassAndModuleCamelCase
1 parent 9eaa1dc commit 081c1ce

File tree

9 files changed

+82
-77
lines changed

9 files changed

+82
-77
lines changed

.rubocop_todo.yml

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2023-12-21 07:51:18 UTC using RuboCop version 1.48.1.
3+
# on 2025-11-03 04:58:59 UTC using RuboCop version 1.50.2.
44
# The point is for the user to remove these configuration records
55
# one by one as the offenses are removed from the code base.
66
# Note that changes in the inspected code, or installation of new
@@ -10,28 +10,17 @@
1010
Lint/UselessAssignment:
1111
Enabled: false
1212

13-
# Offense count: 1
14-
# Configuration parameters: AllowedNames.
15-
# AllowedNames: module_parent
16-
Naming/ClassAndModuleCamelCase:
17-
Exclude:
18-
- 'tooling/kube_tool.rb'
1913

2014
# Offense count: 2640
2115
# Configuration parameters: EnforcedStyle, AllowedIdentifiers, AllowedPatterns.
2216
# SupportedStyles: snake_case, camelCase
2317
Naming/VariableName:
2418
Enabled: false
2519

26-
# Offense count: 41
27-
# Configuration parameters: EnforcedStyle, IgnoreSharedExamples.
28-
# SupportedStyles: always, named_only
29-
RSpec/NamedSubject:
30-
Exclude:
31-
- 'spec/classes/config/kubeadm_spec.rb'
32-
- 'spec/classes/kube_addons_spec.rb'
33-
- 'spec/classes/packages_spec.rb'
34-
- 'spec/classes/repos_spec.rb'
35-
- 'spec/classes/service_spec.rb'
36-
- 'spec/defines/kubeadm_join_spec.rb'
37-
- 'spec/defines/wait_for_default_sa_spec.rb'
20+
# Offense count: 2112
21+
# This cop supports safe autocorrection (--autocorrect).
22+
# Configuration parameters: EnforcedStyle, EnforcedShorthandSyntax, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
23+
# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
24+
# SupportedShorthandSyntax: always, never, either, consistent
25+
Style/HashSyntax:
26+
Enabled: false

spec/classes/config/kubeadm_spec.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
require 'spec_helper'
44
describe 'kubernetes::config::kubeadm', type: :class do
5+
subject(:catalogue) { catalogue }
6+
57
let(:pre_condition) { 'include kubernetes' }
68
let(:facts) do
79
{
@@ -300,7 +302,7 @@
300302
end
301303

302304
it {
303-
expect(subject).to contain_file('/etc/kubernetes/config.yaml') \
305+
expect(catalogue).to contain_file('/etc/kubernetes/config.yaml') \
304306
.with_content(%r{clusterName: my_own_name\n})
305307
}
306308
end
@@ -314,7 +316,7 @@
314316
end
315317

316318
it {
317-
expect(subject).to contain_file('/etc/kubernetes/config.yaml') \
319+
expect(catalogue).to contain_file('/etc/kubernetes/config.yaml') \
318320
.with_content(%r{clusterName: my_own_name\n})
319321
}
320322
end
@@ -593,7 +595,7 @@
593595
let(:config_yaml) { YAML.load_stream(catalogue.resource('file', '/etc/kubernetes/config.yaml').send(:parameters)[:content]) }
594596

595597
it {
596-
expect(subject).to contain_file('/etc/kubernetes/config.yaml') \
598+
expect(catalogue).to contain_file('/etc/kubernetes/config.yaml') \
597599
.with_content(%r{key: node-role.kubernetes.io/control-plane\n})
598600
}
599601
end

spec/classes/kube_addons_spec.rb

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
require 'spec_helper'
44
describe 'kubernetes::kube_addons', type: :class do
5+
subject(:catalogue) { catalogue }
6+
57
let(:pre_condition) { 'include kubernetes' }
68
let(:facts) do
79
{
@@ -32,17 +34,17 @@
3234
end
3335

3436
it {
35-
expect(subject).to contain_exec('Install calico rbac bindings').with({
36-
command: ['kubectl', 'apply', '-f', 'foo'],
37-
onlyif: ['kubectl get nodes']
38-
})
37+
expect(catalogue).to contain_exec('Install calico rbac bindings').with({
38+
command: ['kubectl', 'apply', '-f', 'foo'],
39+
onlyif: ['kubectl get nodes']
40+
})
3941
}
4042

4143
it {
42-
expect(subject).to contain_exec('Install cni network provider').with({
43-
command: ['kubectl', 'apply', '-f', 'https://foo.test'],
44-
onlyif: ['kubectl get nodes']
45-
})
44+
expect(catalogue).to contain_exec('Install cni network provider').with({
45+
command: ['kubectl', 'apply', '-f', 'https://foo.test'],
46+
onlyif: ['kubectl get nodes']
47+
})
4648
}
4749

4850
it { is_expected.to contain_exec('schedule on controller') }
@@ -72,18 +74,20 @@
7274
case provider
7375
when 'calico-tigera'
7476
it {
75-
expect(subject).to contain_exec('Install cni network (preinstall)').with({
76-
command: ['kubectl', 'create', '-f', 'https://foo.test/tigera-operator'],
77-
onlyif: 'kubectl get nodes'
78-
})
77+
expect(catalogue).to contain_exec('Install cni network (preinstall)').with(
78+
{
79+
command: ['kubectl', 'create', '-f', 'https://foo.test/tigera-operator'],
80+
onlyif: 'kubectl get nodes'
81+
},
82+
)
7983
}
8084

8185
it { is_expected.to contain_file('/etc/kubernetes/calico-installation.yaml') }
8286
it { is_expected.to contain_file_line('Configure calico ipPools.cidr') }
8387
it { is_expected.to contain_exec('Install cni network provider') }
8488
when 'flannel'
8589
it {
86-
expect(subject).to contain_exec('Install cni network provider').with(
90+
expect(catalogue).to contain_exec('Install cni network provider').with(
8791
{
8892
onlyif: ['kubectl get nodes'],
8993
command: ['kubectl', 'create', '-f', "https://#{provider}.test"],
@@ -93,17 +97,17 @@
9397
}
9498
else
9599
it {
96-
expect(subject).to contain_exec('Install cni network provider').with({
97-
onlyif: ['kubectl get nodes'],
98-
command: ['kubectl', 'apply', '-f', "https://#{provider}.test"],
99-
unless: ['kubectl -n kube-system get daemonset | egrep "(flannel|weave|calico-node|cilium)"']
100-
})
100+
expect(catalogue).to contain_exec('Install cni network provider').with({
101+
onlyif: ['kubectl get nodes'],
102+
command: ['kubectl', 'apply', '-f', "https://#{provider}.test"],
103+
unless: ['kubectl -n kube-system get daemonset | egrep "(flannel|weave|calico-node|cilium)"']
104+
})
101105
}
102106

103107
it {
104-
expect(subject).not_to contain_exec('Install cni network (preinstall)').with({
105-
onlyif: ['kubectl get nodes']
106-
})
108+
expect(catalogue).not_to contain_exec('Install cni network (preinstall)').with({
109+
onlyif: ['kubectl get nodes']
110+
})
107111
}
108112
end
109113
end

spec/classes/packages_spec.rb

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
require 'spec_helper'
44
describe 'kubernetes::packages', type: :class do
5+
subject(:catalogue) { catalogue }
6+
57
let(:pre_condition) do
68
[
79
'include kubernetes',
@@ -330,105 +332,105 @@
330332
it { is_expected.to contain_file('/etc/containerd/config.toml').without_source }
331333

332334
it {
333-
expect(subject).to contain_file('/etc/containerd/config.toml').with_content(
335+
expect(catalogue).to contain_file('/etc/containerd/config.toml').with_content(
334336
%r{\s*\[plugins."io.containerd.grpc.v1.cri".registry.mirrors."docker.io"\]\s*},
335337
)
336338
}
337339

338340
it {
339-
expect(subject).to contain_file('/etc/containerd/config.toml').with_content(
341+
expect(catalogue).to contain_file('/etc/containerd/config.toml').with_content(
340342
%r{\s*endpoint = \["https://registry-1.docker.io"\]\s*},
341343
)
342344
}
343345

344346
it {
345-
expect(subject).to contain_file('/etc/containerd/config.toml').without_content(
347+
expect(catalogue).to contain_file('/etc/containerd/config.toml').without_content(
346348
%r{\s*\[plugins."io.containerd.grpc.v1.cri".registry.mirrors."docker.private.example.com"\]\s*},
347349
)
348350
}
349351

350352
it {
351-
expect(subject).to contain_file('/etc/containerd/config.toml').with_content(
353+
expect(catalogue).to contain_file('/etc/containerd/config.toml').with_content(
352354
%r{\s*\[plugins."io.containerd.grpc.v1.cri".registry.mirrors."docker.even-more-private.example.com"\]\s*},
353355
)
354356
}
355357

356358
it {
357-
expect(subject).to contain_file('/etc/containerd/config.toml').with_content(
359+
expect(catalogue).to contain_file('/etc/containerd/config.toml').with_content(
358360
%r{\s*endpoint = \["https://docker.even-more-private.example.com"\]\s*},
359361
)
360362
}
361363

362364
it {
363-
expect(subject).to contain_file('/etc/containerd/config.toml').with_content(
365+
expect(catalogue).to contain_file('/etc/containerd/config.toml').with_content(
364366
%r{\s*\[plugins."io.containerd.grpc.v1.cri".registry.configs."docker.private.example.com".auth\]\s*},
365367
)
366368
}
367369

368370
it {
369-
expect(subject).to contain_file('/etc/containerd/config.toml').with_content(
371+
expect(catalogue).to contain_file('/etc/containerd/config.toml').with_content(
370372
%r{\s*auth = "1azhzLXVuaXQtdGVzdDpCQ0NwNWZUUXlyd3c1aUxoMXpEQXJnUT=="\s*},
371373
)
372374
}
373375

374376
it {
375-
expect(subject).to contain_file('/etc/containerd/config.toml').with_content(
377+
expect(catalogue).to contain_file('/etc/containerd/config.toml').with_content(
376378
%r{\s*username = "user2"\s*},
377379
)
378380
}
379381

380382
it {
381-
expect(subject).to contain_file('/etc/containerd/config.toml').with_content(
383+
expect(catalogue).to contain_file('/etc/containerd/config.toml').with_content(
382384
%r{\s*password = "secret2"\s*},
383385
)
384386
}
385387

386388
it {
387-
expect(subject).to contain_file('/etc/containerd/config.toml').with_content(
389+
expect(catalogue).to contain_file('/etc/containerd/config.toml').with_content(
388390
%r{\s*identitytoken = "azhzLXVuaXQtdGVzdDpCQ0NwNWZUUXlyd3c1aUxoMXpEQXJnUT"\s*},
389391
)
390392
}
391393

392394
it {
393-
expect(subject).to contain_file('/etc/containerd/config.toml').with_content(
395+
expect(catalogue).to contain_file('/etc/containerd/config.toml').with_content(
394396
%r{\s*\[plugins."io.containerd.grpc.v1.cri".registry.configs."docker.private.example.com".tls\]\s*},
395397
)
396398
}
397399

398400
it {
399-
expect(subject).to contain_file('/etc/containerd/config.toml').with_content(
401+
expect(catalogue).to contain_file('/etc/containerd/config.toml').with_content(
400402
%r{\s*ca_file = "ca1.pem"\s*},
401403
)
402404
}
403405

404406
it {
405-
expect(subject).to contain_file('/etc/containerd/config.toml').with_content(
407+
expect(catalogue).to contain_file('/etc/containerd/config.toml').with_content(
406408
%r{\s*cert_file = "cert1.pem"\s*},
407409
)
408410
}
409411

410412
it {
411-
expect(subject).to contain_file('/etc/containerd/config.toml').with_content(
413+
expect(catalogue).to contain_file('/etc/containerd/config.toml').with_content(
412414
%r{\s*key_file = "key1.pem"\s*},
413415
)
414416
}
415417

416418
it {
417-
expect(subject).to contain_file('/etc/containerd/config.toml').with_content(
419+
expect(catalogue).to contain_file('/etc/containerd/config.toml').with_content(
418420
%r{\s*insecure_skip_verify = true\s*},
419421
)
420422
}
421423

422424
it {
423-
expect(subject).to contain_file('/etc/containerd/config.toml').with_content(
425+
expect(catalogue).to contain_file('/etc/containerd/config.toml').with_content(
424426
%r{\s*ca_file = "ca2.pem"\s*},
425427
)
426428
}
427429

428430
it { is_expected.not_to contain_file('/etc/apt/preferences.d/containerd') }
429431

430432
it {
431-
expect(subject).to contain_file('/etc/containerd/config.toml').with_content(
433+
expect(catalogue).to contain_file('/etc/containerd/config.toml').with_content(
432434
%r{\saddress = "/run/containerd/containerd.sock"},
433435
)
434436
}
@@ -981,13 +983,13 @@
981983
it { is_expected.to contain_file('/etc/containerd/config.toml') }
982984

983985
it {
984-
expect(subject).to contain_file('/etc/containerd/config.toml').with_content(
986+
expect(catalogue).to contain_file('/etc/containerd/config.toml').with_content(
985987
%r{\s*\[plugins."io.containerd.grpc.v1.cri".registry.mirrors."docker.io"\]\s*},
986988
)
987989
}
988990

989991
it {
990-
expect(subject).to contain_file('/etc/containerd/config.toml').with_content(
992+
expect(catalogue).to contain_file('/etc/containerd/config.toml').with_content(
991993
%r{\s*endpoint = \["https://registry-1.docker.io"\]\s*},
992994
)
993995
}
@@ -1160,7 +1162,7 @@
11601162
it { is_expected.not_to contain_file('/etc/systemd/system/docker.service.d') }
11611163

11621164
it {
1163-
expect(subject).to contain_file('/etc/containerd/config.toml').with_content(
1165+
expect(catalogue).to contain_file('/etc/containerd/config.toml').with_content(
11641166
%r{\saddress = "unix:///run/containerd/containerd.sock"},
11651167
)
11661168
}

spec/classes/repos_spec.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
require 'spec_helper'
44
describe 'kubernetes::repos', type: :class do
5+
subject(:catalogue) { catalogue }
6+
57
context 'with osfamily => Ubuntu and manage_docker => true' do
68
let(:facts) do
79
{
@@ -43,7 +45,7 @@
4345
end
4446

4547
it {
46-
expect(subject).to contain_apt__source('kubernetes').with(
48+
expect(catalogue).to contain_apt__source('kubernetes').with(
4749
ensure: 'present',
4850
location: 'https://pkgs.k8s.io/core:/stable:/v1.32/deb/',
4951
repos: ' ',
@@ -53,7 +55,7 @@
5355
}
5456

5557
it {
56-
expect(subject).to contain_apt__source('docker').with(
58+
expect(catalogue).to contain_apt__source('docker').with(
5759
ensure: 'present',
5860
location: 'https://download.docker.com/linux/debian',
5961
repos: 'main',
@@ -104,7 +106,7 @@
104106
end
105107

106108
it {
107-
expect(subject).to contain_apt__source('kubernetes').with(
109+
expect(catalogue).to contain_apt__source('kubernetes').with(
108110
ensure: 'present',
109111
location: 'https://pkgs.k8s.io/core:/stable:/v1.32/deb/',
110112
repos: ' ',
@@ -114,7 +116,7 @@
114116
}
115117

116118
it {
117-
expect(subject).to contain_apt__source('docker').with(
119+
expect(catalogue).to contain_apt__source('docker').with(
118120
ensure: 'present',
119121
location: 'https://download.docker.com/linux/debian',
120122
repos: 'main',

0 commit comments

Comments
 (0)