diff --git a/cookbooks/fb_bookworm/files/default/bookworm/reports/RecipeOnlyCookbooks.rb b/cookbooks/fb_bookworm/files/default/bookworm/reports/RecipeOnlyCookbooks.rb new file mode 100644 index 000000000..49617c2b1 --- /dev/null +++ b/cookbooks/fb_bookworm/files/default/bookworm/reports/RecipeOnlyCookbooks.rb @@ -0,0 +1,35 @@ +# Copyright (c) 2023-present, Meta, Inc. +# All rights reserved. +# +# 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. +description 'Determines all cookbooks that do not evaluate Ruby code on load' +needs_rules %w{ + MetadatarbExists + AttributeExists + LibraryExists + ResourceExists + ProviderExists +} + +def to_a + cookbooks = Set.new(@kb.cookbooks.keys) + cookbooks.subtract(Set.new(@kb.attributes.map { |_, c| c['cookbook'] })) + cookbooks.subtract(Set.new(@kb.libraries.map { |_, c| c['cookbook'] })) + cookbooks.subtract(Set.new(@kb.resources.map { |_, c| c['cookbook'] })) + cookbooks.subtract(Set.new(@kb.providers.map { |_, c| c['cookbook'] })) + cookbooks.to_a.sort +end + +def output + to_a +end diff --git a/cookbooks/fb_bookworm/files/default/bookworm/rules/AttributeExists.rb b/cookbooks/fb_bookworm/files/default/bookworm/rules/AttributeExists.rb new file mode 100644 index 000000000..8ccfd4eb7 --- /dev/null +++ b/cookbooks/fb_bookworm/files/default/bookworm/rules/AttributeExists.rb @@ -0,0 +1,22 @@ +# Copyright (c) 2022-present, Meta, Inc. +# All rights reserved. +# +# 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. +description 'Helper rule to show existence of an attributes file' +keys %w{ + attribute +} + +def output + true +end diff --git a/cookbooks/fb_bookworm/files/default/bookworm/rules/LibraryExists.rb b/cookbooks/fb_bookworm/files/default/bookworm/rules/LibraryExists.rb new file mode 100644 index 000000000..b8b9e2342 --- /dev/null +++ b/cookbooks/fb_bookworm/files/default/bookworm/rules/LibraryExists.rb @@ -0,0 +1,22 @@ +# Copyright (c) 2022-present, Meta, Inc. +# All rights reserved. +# +# 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. +description 'Helper rule to show existence of a library file' +keys %w{ + library +} + +def output + true +end diff --git a/cookbooks/fb_bookworm/files/default/bookworm/rules/MetadatarbExists.rb b/cookbooks/fb_bookworm/files/default/bookworm/rules/MetadatarbExists.rb new file mode 100644 index 000000000..c1da95d22 --- /dev/null +++ b/cookbooks/fb_bookworm/files/default/bookworm/rules/MetadatarbExists.rb @@ -0,0 +1,22 @@ +# Copyright (c) 2022-present, Meta, Inc. +# All rights reserved. +# +# 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. +description 'Helper rule to show existence of a metadata.rb file' +keys %w{ + metadatarb +} + +def output + true +end diff --git a/cookbooks/fb_bookworm/files/default/bookworm/rules/ProviderExists.rb b/cookbooks/fb_bookworm/files/default/bookworm/rules/ProviderExists.rb new file mode 100644 index 000000000..d0b2ebd53 --- /dev/null +++ b/cookbooks/fb_bookworm/files/default/bookworm/rules/ProviderExists.rb @@ -0,0 +1,22 @@ +# Copyright (c) 2022-present, Meta, Inc. +# All rights reserved. +# +# 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. +description 'Helper rule to show existence of a provider file' +keys %w{ + provider +} + +def output + true +end diff --git a/cookbooks/fb_bookworm/files/default/bookworm/rules/RecipeExists.rb b/cookbooks/fb_bookworm/files/default/bookworm/rules/RecipeExists.rb new file mode 100644 index 000000000..5ef88485d --- /dev/null +++ b/cookbooks/fb_bookworm/files/default/bookworm/rules/RecipeExists.rb @@ -0,0 +1,22 @@ +# Copyright (c) 2022-present, Meta, Inc. +# All rights reserved. +# +# 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. +description 'Helper rule to show existence of a recipe' +keys %w{ + recipe +} + +def output + true +end diff --git a/cookbooks/fb_bookworm/files/default/bookworm/rules/ResourceExists.rb b/cookbooks/fb_bookworm/files/default/bookworm/rules/ResourceExists.rb new file mode 100644 index 000000000..49c88d774 --- /dev/null +++ b/cookbooks/fb_bookworm/files/default/bookworm/rules/ResourceExists.rb @@ -0,0 +1,22 @@ +# Copyright (c) 2022-present, Meta, Inc. +# All rights reserved. +# +# 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. +description 'Helper rule to show existence of a resource file' +keys %w{ + resource +} + +def output + true +end