From 877d0d73a7259853491f18908405ab1cf5186d2e Mon Sep 17 00:00:00 2001 From: Ron Lavi Date: Tue, 20 Dec 2022 11:02:02 +0200 Subject: [PATCH 1/8] Fix broken CardTemplate (#321) * Fix broken CardTemplate Using CardTemplate from Foreman in foreman_puppet v4.0.3, led to the puppet tab not functioning. * Fix linter issue with a padding attribute * Update the foreman core version in the CI --- .github/workflows/ruby_tests.yml | 2 +- .../PuppetTab/SubTabs/ENCPreview/index.js | 2 +- .../Reports/components/DescriptionCard.js | 120 +++++++++++------- 3 files changed, 74 insertions(+), 50 deletions(-) diff --git a/.github/workflows/ruby_tests.yml b/.github/workflows/ruby_tests.yml index c2fa383f..d7e0ca53 100644 --- a/.github/workflows/ruby_tests.yml +++ b/.github/workflows/ruby_tests.yml @@ -37,7 +37,7 @@ jobs: fail-fast: true matrix: foreman-repo: [theforeman/foreman] - foreman-core-branch: [develop] + foreman-core-branch: [3.3-stable] ruby-version: [2.7] node-version: [12] steps: diff --git a/webpack/src/Extends/Host/PuppetTab/SubTabs/ENCPreview/index.js b/webpack/src/Extends/Host/PuppetTab/SubTabs/ENCPreview/index.js index c6617a9d..1600c13c 100644 --- a/webpack/src/Extends/Host/PuppetTab/SubTabs/ENCPreview/index.js +++ b/webpack/src/Extends/Host/PuppetTab/SubTabs/ENCPreview/index.js @@ -36,7 +36,7 @@ const ENCPreview = ({ hostName }) => { } if (response !== '' || response !== undefined) { return ( -
+
); diff --git a/webpack/src/Extends/Host/PuppetTab/SubTabs/Reports/components/DescriptionCard.js b/webpack/src/Extends/Host/PuppetTab/SubTabs/Reports/components/DescriptionCard.js index 452e000a..b51c8771 100644 --- a/webpack/src/Extends/Host/PuppetTab/SubTabs/Reports/components/DescriptionCard.js +++ b/webpack/src/Extends/Host/PuppetTab/SubTabs/Reports/components/DescriptionCard.js @@ -1,7 +1,11 @@ import PropTypes from 'prop-types'; import React from 'react'; -import CardTemplate from 'foremanReact/components/HostDetails/Templates/CardItem/CardTemplate'; import { + Card, + CardBody, + CardHeader, + CardTitle, + CardExpandableContent, DescriptionList, DescriptionListTerm, DescriptionListGroup, @@ -19,53 +23,73 @@ const DescriptionCard = ({ caProxyId, env, status, -}) => ( - - - - {__('Puppet environment')} - - } - status={status} - > - {env && ( - - {env} - - )} - - - - - {__('Puppet Smart Proxy')} - - } - status={status} - > - {proxyName && ( - {proxyName} - )} - - - - - {__('Puppet CA Smart Proxy')} - - } - status={status} - > - {caProxy && ( - {caProxy} - )} - - - - - -); +}) => { + const [isExpanded, setIsExpanded] = React.useState(false); + return ( + + setIsExpanded(v => !v)}> + {__('Puppet details')} + + + + + + + {__('Puppet environment')} + + + } + status={status} + > + {env && ( + + {env} + + )} + + + + + + {__('Puppet Smart Proxy')} + + + } + status={status} + > + {proxyName && ( + {proxyName} + )} + + + + + + {__('Puppet CA Smart Proxy')} + + + } + status={status} + > + {caProxy && ( + + {caProxy} + + )} + + + + + + + + ); +}; DescriptionCard.propTypes = { caProxy: PropTypes.string, From 59a66f18ed59f643d78c0a34af734d305a64ac3e Mon Sep 17 00:00:00 2001 From: Ron Lavi Date: Tue, 20 Dec 2022 16:33:51 +0200 Subject: [PATCH 2/8] Bump foreman_puppet to 4.0.4 (#326) --- lib/foreman_puppet/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/foreman_puppet/version.rb b/lib/foreman_puppet/version.rb index 8d0c6b28..3ffd10b7 100644 --- a/lib/foreman_puppet/version.rb +++ b/lib/foreman_puppet/version.rb @@ -1,3 +1,3 @@ module ForemanPuppet - VERSION = '4.0.3'.freeze + VERSION = '4.0.4'.freeze end From f89e904dcd579dccbdf848bbb20c82cc62876e7f Mon Sep 17 00:00:00 2001 From: Kamil Szubrycht Date: Wed, 21 Dec 2022 08:51:13 +0100 Subject: [PATCH 3/8] GraphQL: Fix graphql tests (#322) (#324) * GraphQL: Fix graphql tests (#322) * GraphQL: Fix create host mutation test * GraphQL: fix loading puppetclass taxonomies (cherry picked from commit 41ab916bbbc78cfdaff8fa7723df88165f31cbda) * Update tests matrix --- .github/workflows/ruby_tests.yml | 2 +- app/models/foreman_puppet/puppetclass.rb | 4 ++-- test/graphql/mutations/hosts/create_mutation_test.rb | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ruby_tests.yml b/.github/workflows/ruby_tests.yml index d7e0ca53..7c5c59f6 100644 --- a/.github/workflows/ruby_tests.yml +++ b/.github/workflows/ruby_tests.yml @@ -37,7 +37,7 @@ jobs: fail-fast: true matrix: foreman-repo: [theforeman/foreman] - foreman-core-branch: [3.3-stable] + foreman-core-branch: [3.4-stable] ruby-version: [2.7] node-version: [12] steps: diff --git a/app/models/foreman_puppet/puppetclass.rb b/app/models/foreman_puppet/puppetclass.rb index 2780cf6b..84ae6018 100644 --- a/app/models/foreman_puppet/puppetclass.rb +++ b/app/models/foreman_puppet/puppetclass.rb @@ -15,8 +15,8 @@ class Puppetclass < ApplicationRecord before_destroy EnsureNotUsedBy.new(:hosts, :hostgroups) has_many :environment_classes, dependent: :destroy, inverse_of: :puppetclass has_many :environments, -> { distinct }, through: :environment_classes - has_many :organizations, -> { distinct.reorder(nil) }, through: :environments - has_many :locations, -> { distinct.reorder(nil) }, through: :environments + has_many :organizations, -> { distinct.reorder(:id) }, through: :environments + has_many :locations, -> { distinct.reorder(:id) }, through: :environments # rubocop:disable Rails/HasAndBelongsToMany has_and_belongs_to_many :operatingsystems diff --git a/test/graphql/mutations/hosts/create_mutation_test.rb b/test/graphql/mutations/hosts/create_mutation_test.rb index 97e775ba..ba722ca2 100644 --- a/test/graphql/mutations/hosts/create_mutation_test.rb +++ b/test/graphql/mutations/hosts/create_mutation_test.rb @@ -72,7 +72,7 @@ class CreateMutationTest < GraphQLQueryTestCase assert_equal 1, host.interfaces.count interface = host.interfaces.first assert_equal 'Nic::Bond', interface.type - assert_equal 'eth0, eth1', interface.attached_to + assert_same_elements %w[eth0 eth1], interface.attached_to.split(', ') assert_equal 'bond0', interface.identifier assert interface.primary assert interface.provision From 4862d343eb2001214453999982c8d3eee4f17fe7 Mon Sep 17 00:00:00 2001 From: Ron Lavi Date: Thu, 22 Dec 2022 10:46:12 +0200 Subject: [PATCH 4/8] Bump foreman_puppet to 4.1.0 (#327) Splitting to 4.0-stable branch: |Foreman version|Plugin version| |---------------|--------------| | ~> 3.4 | ~> 4.1 | | ~> 3.3 | ~> 4.0 | --- README.md | 5 +++-- lib/foreman_puppet/version.rb | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 209835bf..6281431e 100644 --- a/README.md +++ b/README.md @@ -37,8 +37,9 @@ You can install it on Foreman 2.5 to prepare for the Foreman update. |Foreman version|Plugin version|Notes | |---------------|--------------|------------------------------------------| -| >= 3.3 | ~> 4.0 | Required | -| >= 3.2 | ~> 3.0 | Required | +| ~> 3.4 | ~> 4.1 | Required | +| ~> 3.3 | ~> 4.0 | Required | +| ~> 3.2 | ~> 3.0 | Required | | ~> 3.1 | ~> 2.0 | Required | | ~> 3.0 | ~> 1.0 | Required | | >= 2.5 | ~> 0.1 | Optional; replaces Core features | diff --git a/lib/foreman_puppet/version.rb b/lib/foreman_puppet/version.rb index 3ffd10b7..d6d13a18 100644 --- a/lib/foreman_puppet/version.rb +++ b/lib/foreman_puppet/version.rb @@ -1,3 +1,3 @@ module ForemanPuppet - VERSION = '4.0.4'.freeze + VERSION = '4.1.0'.freeze end From ab289f86b14ea266e5c74750fddc4d7866a4b0f7 Mon Sep 17 00:00:00 2001 From: Manisha15 Date: Mon, 27 Feb 2023 17:38:32 +0100 Subject: [PATCH 5/8] Fixes Host view permissions to search by puppetclass (cherry picked from commit 3722ec58614fa5bcc2db397f0a372f4d038bc256) --- app/models/concerns/foreman_puppet/extensions/host.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/concerns/foreman_puppet/extensions/host.rb b/app/models/concerns/foreman_puppet/extensions/host.rb index bf2fc87c..f2adf5e5 100644 --- a/app/models/concerns/foreman_puppet/extensions/host.rb +++ b/app/models/concerns/foreman_puppet/extensions/host.rb @@ -30,7 +30,7 @@ def search_by_deprecated_class(key, operator, value) def search_by_puppetclass(_key, operator, value) conditions = sanitize_sql_for_conditions(["puppetclasses.name #{operator} ?", value_to_sql(operator, value)]) config_group_ids = ForemanPuppet::ConfigGroup.joins(:puppetclasses).where(conditions).pluck(:id) - host_ids = ::Host.authorized(:view_hosts, Host).joins(puppet: :puppetclasses).where(conditions).distinct.pluck(:id) + host_ids = ::Host.authorized(:view_hosts).joins(puppet: :puppetclasses).where(conditions).distinct.pluck(:id) host_ids += ForemanPuppet::HostConfigGroup .where(host_type: 'ForemanPuppet::HostPuppetFacet') .where(config_group_id: config_group_ids) From 2a706a1a6c6d28ca79892f4e577501895ef5a534 Mon Sep 17 00:00:00 2001 From: Nadja Heitmann Date: Tue, 21 Feb 2023 11:31:24 +0000 Subject: [PATCH 6/8] Remove plugin example task from code base (cherry picked from commit a49481302dd83b9bdc5de17b246b155536567445) --- lib/tasks/foreman_puppet_tasks.rake | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/lib/tasks/foreman_puppet_tasks.rake b/lib/tasks/foreman_puppet_tasks.rake index cd428ee6..b2860054 100644 --- a/lib/tasks/foreman_puppet_tasks.rake +++ b/lib/tasks/foreman_puppet_tasks.rake @@ -1,15 +1,5 @@ require 'rake/testtask' -# Tasks -namespace :foreman_puppet do - namespace :example do - desc 'Example Task' - task task: :environment do - # Task goes here - end - end -end - # Tests namespace :test do desc 'Test ForemanPuppet' From 71c1b5fbf6b97e109675e652d210208798dc5e85 Mon Sep 17 00:00:00 2001 From: Ron Lavi <1ronlavi@gmail.com> Date: Thu, 2 Feb 2023 15:32:22 +0200 Subject: [PATCH 7/8] add static ouiaID in foreman_puppet sub tabs (cherry picked from commit d98361e42b044c8e213ce03661fd678e600bc74a) --- webpack/src/Extends/Host/PuppetTab/index.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/webpack/src/Extends/Host/PuppetTab/index.js b/webpack/src/Extends/Host/PuppetTab/index.js index 325164e9..216cf340 100644 --- a/webpack/src/Extends/Host/PuppetTab/index.js +++ b/webpack/src/Extends/Host/PuppetTab/index.js @@ -21,6 +21,8 @@ const PuppetTab = ({ response, status, location: { pathname } }) => { {SECONDARY_TABS.map(({ key, title }) => ( {title}} /> From 1f0ceaad6176b1f0c213708167e5b6dfa1585ba7 Mon Sep 17 00:00:00 2001 From: Nadja Heitmann Date: Wed, 1 Mar 2023 13:01:41 +0100 Subject: [PATCH 8/8] Bump foreman_puppet to 4.1.1 --- lib/foreman_puppet/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/foreman_puppet/version.rb b/lib/foreman_puppet/version.rb index d6d13a18..42c296e4 100644 --- a/lib/foreman_puppet/version.rb +++ b/lib/foreman_puppet/version.rb @@ -1,3 +1,3 @@ module ForemanPuppet - VERSION = '4.1.0'.freeze + VERSION = '4.1.1'.freeze end