Skip to content

Commit

Permalink
VM - Fix chefdk and foodcritic deprecation (#1699)
Browse files Browse the repository at this point in the history
  • Loading branch information
armandomiani authored Apr 1, 2022
1 parent 38c7474 commit 005212f
Show file tree
Hide file tree
Showing 12 changed files with 51 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
with:
python-version: '3.x'
- name: Install dependencies
run: |
run: |
python -m pip install --upgrade pip jinja2 pyyaml
wget https://packages.chef.io/files/stable/chefdk/4.2.0/ubuntu/16.04/chefdk_4.2.0-1_amd64.deb
sudo dpkg -i chefdk_4.2.0-1_amd64.deb
Expand Down
12 changes: 4 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,13 @@ python-test: ## Runs tests for Python scripts

.PHONY: vm-lint
vm-lint: ## Runs lint for Chef cookbooks
@docker pull chef/chefdk
@docker pull chef/chefworkstation
# cookstyle print version
@docker run --rm --entrypoint cookstyle -v $(PWD)/vm/chef:/chef:ro chef/chefdk --version
@docker run --rm --entrypoint cookstyle -v $(PWD)/vm/chef:/chef:ro chef/chefworkstation --version
# cookstyle on cookbooks
@docker run --rm --entrypoint cookstyle -v $(PWD)/vm/chef:/chef:ro chef/chefdk /chef/cookbooks
@docker run --rm --entrypoint cookstyle -v $(PWD)/vm/chef:/chef:ro chef/chefworkstation /chef/cookbooks
# cookstyle on tests
@docker run --rm --entrypoint cookstyle -v $(PWD)/vm/tests:/tests:ro chef/chefdk /tests/solutions
# foodcritic print version
@docker run --rm --entrypoint foodcritic -v $(PWD)/vm/chef:/chef:ro chef/chefdk --version
# foodcritic on cookbooks
@docker run --rm --entrypoint foodcritic -v $(PWD)/vm/chef:/chef:ro chef/chefdk --cookbook-path=/chef/cookbooks --rule-file=/chef/.foodcritic --epic-fail=any
@docker run --rm --entrypoint cookstyle -v $(PWD)/vm/tests:/tests:ro chef/chefworkstation /tests/solutions

.PHONY: vm-generate-triggers
vm-generate-triggers: ## Generates and displays GCB triggers for VM
Expand Down
18 changes: 9 additions & 9 deletions vm/chef/.rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
ChefStyle/CommentFormat:
Chef/Style/CommentFormat:
Enabled: false

ChefCorrectness/TmpPath:
Chef/Correctness/TmpPath:
Enabled: false

ChefStyle/FileMode:
Chef/Style/FileMode:
Enabled: false

Style/BracesAroundHashParameters:
Style/WordArray:
Enabled: false

# TODO(wgrzelak): Fix code and remove the rule.
ChefRedundantCode/NamePropertyIsRequired:
Chef/Modernize/CronDFileOrTemplate:
Enabled: false

Style/WordArray:
Enabled: false
# TODO(armadom): Fix code and remove the rule.
Chef/RedundantCode/NamePropertyIsRequired:
Enabled: false

Style/HashSyntax:
Chef/Correctness/MetadataMissingVersion:
Enabled: false
15 changes: 15 additions & 0 deletions vm/chef/cookbooks/apache2/resources/allow_override.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

property :directory, String, default: ''
unified_mode true

action :apply do
bash 'Create template' do
Expand Down
4 changes: 3 additions & 1 deletion vm/chef/cookbooks/c2d-config/resources/c2d_startup_script.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2018 Google LLC
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -46,6 +46,8 @@

default_action :cookbook_file

unified_mode true

c2d_startup_count = 0
c2d_startup_dir = '/opt/c2d/scripts'

Expand Down
10 changes: 5 additions & 5 deletions vm/chef/cookbooks/mysql/recipes/install-and-configure-mysqld.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2018 Google LLC
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -21,10 +21,10 @@

template '/etc/mysql/mysql.conf.d/mysqld.cnf' do
source 'mysqld.cnf.erb'
variables(
:bind_address => node['mysql']['bind_address'],
:log_bin_trust_function_creators => node['mysql']['log_bin_trust_function_creators']
)
variables({
bind_address: node['mysql']['bind_address'],
log_bin_trust_function_creators: node['mysql']['log_bin_trust_function_creators'],
})
end

c2d_startup_script 'mysql'
Expand Down
10 changes: 5 additions & 5 deletions vm/chef/cookbooks/mysql/recipes/install-and-configure-mysqld8.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2018 Google LLC
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -21,10 +21,10 @@

template '/etc/mysql/mysql.conf.d/mysqld.cnf' do
source 'mysqld8.cnf.erb'
variables(
:bind_address => node['mysql']['bind_address'],
:log_bin_trust_function_creators => node['mysql']['log_bin_trust_function_creators']
)
variables({
bind_address: node['mysql']['bind_address'],
log_bin_trust_function_creators: node['mysql']['log_bin_trust_function_creators'],
})
end

c2d_startup_script 'mysql'
Expand Down
4 changes: 2 additions & 2 deletions vm/chef/cookbooks/nginx/recipes/stretch-backports.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2021 Google LLC
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

package 'install packages' do # ~FC009
package 'install packages' do
package_name node['nginx']['packages']
default_release 'stretch-backports'
action :install
Expand Down
3 changes: 2 additions & 1 deletion vm/chef/cookbooks/nodenvm/resources/npm.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2021 Google LLC
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -14,6 +14,7 @@

property :package, String, default: ''
property :cwd, String, default: '/'
unified_mode true

action :install do
bash 'Install npm package' do
Expand Down
3 changes: 2 additions & 1 deletion vm/chef/cookbooks/nodenvm/resources/run.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2021 Google LLC
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -14,6 +14,7 @@

property :command, String, default: ''
property :cwd, String, default: '/'
unified_mode true

action :run do
bash 'Run command in node context' do
Expand Down
4 changes: 2 additions & 2 deletions vm/chef/cookbooks/openjdk11/recipes/default.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2018 Google LLC
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -16,7 +16,7 @@
action :update
end

package 'install packages' do # ~FC009
package 'install packages' do
only_if { node['platform_version'].include? '8.' }
package_name node['openjdk11']['packages']
default_release 'jessie-backports'
Expand Down
2 changes: 1 addition & 1 deletion vm/tests/solutions/.rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ChefStyle/CommentFormat:
Chef/Style/CommentFormat:
Enabled: false

Style/HashSyntax:
Expand Down

0 comments on commit 005212f

Please sign in to comment.