summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGene Wood <gene_wood@cementhorizon.com>2022-09-16 14:28:01 -0700
committerGene Wood <gene_wood@cementhorizon.com>2022-09-16 14:28:01 -0700
commit428a95b5212c2cc3ddc233a9078e34f94bc0791e (patch)
treeaf1a94a3a668b3f09a2706d3702a965c0426f608
parent37a97f02edee045e5f8387f7071f67600ea811dd (diff)
downloadchef-428a95b5212c2cc3ddc233a9078e34f94bc0791e.tar.gz
Add allowed_actions for each package type
This will override the allowed_actions setting in the inherited package resource so that the allowed_actions reflects the actual supported actions of each package type. This should enable a better error message from Chef when an unsupported action is called for a given package type as well as enabling the correct automatic generation of Chef documentation for each package type, listing the actual supported actions (instead of all actions). Currently this difference between the rake generated documentation and the real action list is hand corrected after rake generates it as mentioned in #13123. This should remove the need for that. The allowed_actions for each package in this commit is derived from the methods supported by each of the associated Chef providers for each package resource. Fixes #13123 Signed-off-by: Gene Wood <gene_wood@cementhorizon.com>
-rw-r--r--lib/chef/resource/apt_package.rb2
-rw-r--r--lib/chef/resource/dmg_package.rb2
-rw-r--r--lib/chef/resource/freebsd_package.rb2
-rw-r--r--lib/chef/resource/gem_package.rb2
-rw-r--r--lib/chef/resource/homebrew_package.rb2
-rw-r--r--lib/chef/resource/macports_package.rb2
-rw-r--r--lib/chef/resource/openbsd_package.rb2
-rw-r--r--lib/chef/resource/pacman_package.rb2
-rw-r--r--lib/chef/resource/portage_package.rb2
-rw-r--r--lib/chef/resource/rpm_package.rb2
-rw-r--r--lib/chef/resource/smartos_package.rb2
-rw-r--r--lib/chef/resource/snap_package.rb2
-rw-r--r--lib/chef/resource/solaris_package.rb2
-rw-r--r--lib/chef/resource/yum_package.rb2
-rw-r--r--lib/chef/resource/zypper_package.rb2
15 files changed, 30 insertions, 0 deletions
diff --git a/lib/chef/resource/apt_package.rb b/lib/chef/resource/apt_package.rb
index af485d85ec..85c2ad4faf 100644
--- a/lib/chef/resource/apt_package.rb
+++ b/lib/chef/resource/apt_package.rb
@@ -56,6 +56,8 @@ class Chef
description "Use the **apt_package** resource to manage packages on Debian, Ubuntu, and other platforms that use the APT package system."
+ allowed_actions :install, :upgrade, :remove, :purge, :reconfig, :lock, :unlock
+
property :default_release, String,
description: "The default release. For example: `stable`.",
desired_state: false
diff --git a/lib/chef/resource/dmg_package.rb b/lib/chef/resource/dmg_package.rb
index c3bdbf81cd..168388d6f6 100644
--- a/lib/chef/resource/dmg_package.rb
+++ b/lib/chef/resource/dmg_package.rb
@@ -57,6 +57,8 @@ class Chef
```
DOC
+ allowed_actions :install
+
property :app, String,
description: "The name of the application as it appears in the `/Volumes` directory if it differs from the resource block's name.",
name_property: true
diff --git a/lib/chef/resource/freebsd_package.rb b/lib/chef/resource/freebsd_package.rb
index 713aa26e0c..210f2b7233 100644
--- a/lib/chef/resource/freebsd_package.rb
+++ b/lib/chef/resource/freebsd_package.rb
@@ -30,6 +30,8 @@ class Chef
description "Use the **freebsd_package** resource to manage packages for the FreeBSD platform."
+ allowed_actions :install, :remove
+
# make sure we assign the appropriate underlying providers based on what
# package managers exist on this FreeBSD system or the source of the package
#
diff --git a/lib/chef/resource/gem_package.rb b/lib/chef/resource/gem_package.rb
index ab11a873e2..cac751a25c 100644
--- a/lib/chef/resource/gem_package.rb
+++ b/lib/chef/resource/gem_package.rb
@@ -59,6 +59,8 @@ class Chef
```
EXAMPLES
+ allowed_actions :install, :upgrade, :remove, :purge
+
property :package_name, String,
description: "An optional property to set the package name if it differs from the resource block's name.",
identity: true
diff --git a/lib/chef/resource/homebrew_package.rb b/lib/chef/resource/homebrew_package.rb
index 2d8efdb82b..6251fb3c75 100644
--- a/lib/chef/resource/homebrew_package.rb
+++ b/lib/chef/resource/homebrew_package.rb
@@ -60,6 +60,8 @@ class Chef
```
DOC
+ allowed_actions :install, :upgrade, :remove, :purge
+
property :homebrew_user, [ String, Integer ],
description: "The name or uid of the Homebrew owner to be used by #{ChefUtils::Dist::Infra::PRODUCT} when executing a command.\n\n#{ChefUtils::Dist::Infra::PRODUCT}, by default, will attempt to execute a Homebrew command as the owner of the `/usr/local/bin/brew` executable. If that executable does not exist, #{ChefUtils::Dist::Infra::PRODUCT} will attempt to find the user by executing `which brew`. If that executable cannot be found, #{ChefUtils::Dist::Infra::PRODUCT} will print an error message: `Could not find the 'brew' executable in /usr/local/bin or anywhere on the path.`.\n\nSet this property to specify the Homebrew owner for situations where Chef Infra Client cannot automatically detect the correct owner.'"
diff --git a/lib/chef/resource/macports_package.rb b/lib/chef/resource/macports_package.rb
index 702ff0038d..858980f338 100644
--- a/lib/chef/resource/macports_package.rb
+++ b/lib/chef/resource/macports_package.rb
@@ -25,6 +25,8 @@ class Chef
description "Use the **macports_package** resource to manage packages for the macOS platform using the MacPorts package management system."
+ allowed_actions :install, :upgrade, :remove, :purge
+
property :package_name, String,
description: "An optional property to set the package name if it differs from the resource block's name.",
identity: true
diff --git a/lib/chef/resource/openbsd_package.rb b/lib/chef/resource/openbsd_package.rb
index f60c4a0c40..eff4ae28e8 100644
--- a/lib/chef/resource/openbsd_package.rb
+++ b/lib/chef/resource/openbsd_package.rb
@@ -48,6 +48,8 @@ class Chef
```
DOC
+ allowed_actions :install, :remove
+
property :package_name, String,
description: "An optional property to set the package name if it differs from the resource block's name.",
identity: true
diff --git a/lib/chef/resource/pacman_package.rb b/lib/chef/resource/pacman_package.rb
index 99c2fec1d5..dd7bc0ff1a 100644
--- a/lib/chef/resource/pacman_package.rb
+++ b/lib/chef/resource/pacman_package.rb
@@ -24,6 +24,8 @@ class Chef
provides :pacman_package
+ allowed_actions :install, :upgrade, :remove, :purge
+
description "Use the **pacman_package** resource to manage packages (using pacman) on the Arch Linux platform."
end
end
diff --git a/lib/chef/resource/portage_package.rb b/lib/chef/resource/portage_package.rb
index b659cea948..6c263b6619 100644
--- a/lib/chef/resource/portage_package.rb
+++ b/lib/chef/resource/portage_package.rb
@@ -26,6 +26,8 @@ class Chef
description "Use the **portage_package** resource to manage packages for the Gentoo platform."
+ allowed_actions :install, :upgrade, :remove, :purge
+
property :package_name, String,
description: "An optional property to set the package name if it differs from the resource block's name.",
identity: true
diff --git a/lib/chef/resource/rpm_package.rb b/lib/chef/resource/rpm_package.rb
index 31cd279ba8..34b48e3bec 100644
--- a/lib/chef/resource/rpm_package.rb
+++ b/lib/chef/resource/rpm_package.rb
@@ -24,6 +24,8 @@ class Chef
provides :rpm_package
+ allowed_actions :install, :upgrade, :remove
+
description "Use the **rpm_package** resource to manage packages using the RPM Package Manager."
property :allow_downgrade, [ TrueClass, FalseClass ],
diff --git a/lib/chef/resource/smartos_package.rb b/lib/chef/resource/smartos_package.rb
index 2dabccc4b4..429891e53d 100644
--- a/lib/chef/resource/smartos_package.rb
+++ b/lib/chef/resource/smartos_package.rb
@@ -27,6 +27,8 @@ class Chef
description "Use the **smartos_package** resource to manage packages for the SmartOS platform."
+ allowed_actions :install, :upgrade, :remove
+
property :package_name, String,
description: "An optional property to set the package name if it differs from the resource block's name.",
identity: true
diff --git a/lib/chef/resource/snap_package.rb b/lib/chef/resource/snap_package.rb
index 4979e996e0..cb8de2d1f5 100644
--- a/lib/chef/resource/snap_package.rb
+++ b/lib/chef/resource/snap_package.rb
@@ -27,6 +27,8 @@ class Chef
description "Use the **snap_package** resource to manage snap packages on Debian and Ubuntu platforms."
introduced "15.0"
+ allowed_actions :install, :upgrade, :remove, :purge
+
property :channel, String,
description: "The default channel. For example: stable.",
default: "stable",
diff --git a/lib/chef/resource/solaris_package.rb b/lib/chef/resource/solaris_package.rb
index c3d023db35..b2ffb2372b 100644
--- a/lib/chef/resource/solaris_package.rb
+++ b/lib/chef/resource/solaris_package.rb
@@ -27,6 +27,8 @@ class Chef
description "Use the **solaris_package** resource to manage packages on the Solaris platform."
+ allowed_actions :install, :upgrade, :remove
+
property :package_name, String,
description: "An optional property to set the package name if it differs from the resource block's name.",
identity: true
diff --git a/lib/chef/resource/yum_package.rb b/lib/chef/resource/yum_package.rb
index 83b2508ac5..ebdcb867ab 100644
--- a/lib/chef/resource/yum_package.rb
+++ b/lib/chef/resource/yum_package.rb
@@ -109,6 +109,8 @@ class Chef
```
DOC
+ allowed_actions :install, :upgrade, :remove, :purge, :lock, :unlock
+
# XXX: the coercions here are due to the provider promiscuously updating the properties on the
# new_resource which causes immutable modification exceptions when passed an immutable node array.
#
diff --git a/lib/chef/resource/zypper_package.rb b/lib/chef/resource/zypper_package.rb
index a32c79c607..85c55205a5 100644
--- a/lib/chef/resource/zypper_package.rb
+++ b/lib/chef/resource/zypper_package.rb
@@ -53,6 +53,8 @@ class Chef
```
DOC
+ allowed_actions :install, :upgrade, :remove, :purge, :lock, :unlock
+
property :gpg_check, [ TrueClass, FalseClass ],
description: "Verify the package's GPG signature. Can also be controlled site-wide using the `zypper_check_gpg` config option.",
default: lazy { Chef::Config[:zypper_check_gpg] }, default_description: "true"