-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Add new boolean property anchor_package_regex to resource apt_package resource #13873
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
782b344
473dad9
7a8cc3c
22ddef8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -52,6 +52,21 @@ class AptPackage < Chef::Resource::Package | |||||||||
options '--no-install-recommends' | ||||||||||
end | ||||||||||
``` | ||||||||||
|
||||||||||
**Prevent the apt_package resource from installing packages with pattern matching names**: | ||||||||||
|
||||||||||
By default, the apt_package resource will install the named package. | ||||||||||
If it can't find a package with the exact same name, it will treat the package name as regex string and match with any package that matches that regex. | ||||||||||
This may lead Chef Infra Client to install one or more packages with names that match that regex. | ||||||||||
johnmccrae marked this conversation as resolved.
Show resolved
Hide resolved
Comment on lines
+59
to
+60
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://developers.google.com/style/word-list#regex
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This pr was merged without this change. Addressing that in a separate pr #13991 |
||||||||||
|
||||||||||
In this example, `anchor_package_regex true` prevents the apt_package resource from installing matching packages if it can't find the `lua5.3` package. | ||||||||||
johnmccrae marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
|
||||||||||
```ruby | ||||||||||
apt_package 'lua5.3' do | ||||||||||
version '5.3.3-1.1ubuntu2' | ||||||||||
anchor_package_regex true | ||||||||||
end | ||||||||||
``` | ||||||||||
DOC | ||||||||||
|
||||||||||
description "Use the **apt_package** resource to manage packages on Debian, Ubuntu, and other platforms that use the APT package system." | ||||||||||
|
@@ -75,6 +90,10 @@ class AptPackage < Chef::Resource::Package | |||||||||
description: "A Hash of response file variables in the form of {'VARIABLE' => 'VALUE'}.", | ||||||||||
default: {}, desired_state: false | ||||||||||
|
||||||||||
property :anchor_package_regex, [TrueClass, FalseClass], | ||||||||||
introduced: "18.3", | ||||||||||
description: "A Boolean flag that allows (`false`) or prevents (`true`) apt_package from matching the named package with packages by regular expression if it can't find a package with the exact same name.", | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How does this prevent this? What do true and false do? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because the regex anchors specify that the regex pattern must include the entire package name. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The larger description above provides lots of other context. But anything treated like a regular expression means it'll match substrings, so "apache" which would match "apache-mycoolthing" or whatever. This is the short-description, suggestions welcome There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This PR was merged with this change as well, and the description is not accurate as it stands. It claims it's not a regex anymore, but it still is, it's just an anchored one. If someone passes in foo.*bar that'll still work. |
||||||||||
default: false | ||||||||||
end | ||||||||||
end | ||||||||||
end |
Uh oh!
There was an error while loading. Please reload this page.