Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add package mapping capability #2284

wants to merge 1 commit into from

Conversation

guangyee
Copy link
Contributor

@guangyee guangyee commented Mar 2, 2021

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).

lib/salt_states.rb Outdated Show resolved Hide resolved
lib/salt_states.rb Outdated Show resolved Hide resolved
lib/salt_states.rb Outdated Show resolved Hide resolved
lib/salt_states.rb Outdated Show resolved Hide resolved
lib/salt_states.rb Outdated Show resolved Hide resolved
lib/salt_states.rb Outdated Show resolved Hide resolved
lib/salt_states.rb Outdated Show resolved Hide resolved
lib/salt_states.rb Outdated Show resolved Hide resolved
lib/salt_states.rb Show resolved Hide resolved
lib/salt_states.rb Outdated Show resolved Hide resolved

def map_package(name, version, pattern)
if package_has_mapping?(name, version, pattern)
if @package_map[name].is_a?(Hash) &&

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 (

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)

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?

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

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)

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]

package_map_file = File.join(
Machinery::ROOT, "export_helpers/#{@name}_package_map"
)
if File.file?(package_map_file)

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 &&/||.

@@ -382,52 +393,82 @@ def managed_file_states(output_location)
managed_files_sls
end

def add_package(package)
def add_package(name, version, pattern)

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]

Copy link
Collaborator

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).
@@ -95,6 +98,12 @@ def check_existance_of_extracted_files
end
end

def load_package_map
if @options["package-map-file"]

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

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.

Copy link
Collaborator

@jeremy-moffitt jeremy-moffitt left a 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>
Copy link
Collaborator

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)
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants