-
Notifications
You must be signed in to change notification settings - Fork 32
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
Add package mapping capability #2284
base: master
Are you sure you want to change the base?
Conversation
e43ce3d
to
be02b00
Compare
|
||
def map_package(name, version, pattern) | ||
if package_has_mapping?(name, version, pattern) | ||
if @package_map[name].is_a?(Hash) && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layout/TrailingWhitespace: Trailing whitespace detected.
|
||
SALT | ||
def package_version_match?(package_mapping, version) | ||
!package_mapping.include?("version") or ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/AndOr: Use || instead of or.
- version: '#{pattern.version}' | ||
- includes: [pattern] | ||
def package_pattern_match?(package_mapping, pattern) | ||
pattern == package_mapping.fetch('pattern', false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
salt_package += " - includes: [pattern]\n" | ||
end | ||
|
||
if @options["skip-package-version"] or version.nil? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/AndOr: Use || instead of or.
SALT | ||
|
||
if @options["skip-package-version"] | ||
if pattern |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/IfUnlessModifier: Favor modifier if usage when having a single-line body. Another good alternative is the usage of control flow &&/||.
@@ -382,52 +393,81 @@ def managed_file_states(output_location) | |||
managed_files_sls | |||
end | |||
|
|||
def add_package(package) | |||
def add_package(name, version, pattern) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metrics/MethodLength: Method has too many lines. [13/10]
lib/salt_states.rb
Outdated
package_map_file = File.join( | ||
Machinery::ROOT, "export_helpers/#{@name}_package_map" | ||
) | ||
if File.file?(package_map_file) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/GuardClause: Use a guard clause instead of wrapping the code inside a conditional expression.
Style/IfUnlessModifier: Favor modifier if usage when having a single-line body. Another good alternative is the usage of control flow &&/||.
be02b00
to
f3f2af6
Compare
@@ -382,52 +393,82 @@ def managed_file_states(output_location) | |||
managed_files_sls | |||
end | |||
|
|||
def add_package(package) | |||
def add_package(name, version, pattern) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metrics/MethodLength: Method has too many lines. [14/10]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm boggled that hound expects methods to have 10 lines or less
If a given package/pattern in the source machine had been renamed/splitted/removed in the target machine, we need a way to map those packages/patterns into the new packages/patterns. This functionality is expecially helpful for cross-OS migration (i.e. CentOS to openSUSE).
f3f2af6
to
c6b4bf8
Compare
@@ -95,6 +98,12 @@ def check_existance_of_extracted_files | |||
end | |||
end | |||
|
|||
def load_package_map | |||
if @options["package-map-file"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/GuardClause: Use a guard clause instead of wrapping the code inside a conditional expression.
Style/IfUnlessModifier: Favor modifier if usage when having a single-line body. Another good alternative is the usage of control flow &&/||.
@@ -37,12 +37,15 @@ def initialize(system_description, options) | |||
@system_description = system_description | |||
@options = options | |||
@group_id_to_name_mapping = {} | |||
@package_map = \ | |||
options.include?("package-map") ? options["package-map"] : nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layout/IndentAssignment: Indent the first line of the right-hand-side of a multi-line assignment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
outside of the hound issues this largely looks good to me.
version: <target package version> | ||
|
||
# Map a source pattern package. | ||
<source pattern package name> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the above line missing a :
?
@@ -382,52 +393,82 @@ def managed_file_states(output_location) | |||
managed_files_sls | |||
end | |||
|
|||
def add_package(package) | |||
def add_package(name, version, pattern) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm boggled that hound expects methods to have 10 lines or less
If a given package/pattern in the source machine had been
renamed/splitted/removed in the target machine, we need a way to map
those packages/patterns into the new packages/patterns. This functionality
is expecially helpful for cross-OS migration (i.e. CentOS to openSUSE).