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

fixes #17031 - repository info: include mirror on sync #460

Merged
merged 1 commit into from
Oct 20, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions lib/hammer_cli_katello/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class InfoCommand < HammerCLIKatello::InfoCommand
field :_redhat_repo, _("Red Hat Repository")
field :content_type, _("Content Type")
field :checksum_type, _("Checksum Type"), Fields::Field, :hide_blank => true
field :_mirror_on_sync, _("Mirror on Sync")
field :url, _("URL")
field :_publish_via_http, _("Publish Via HTTP")
field :full_path, _("Published At")
Expand Down Expand Up @@ -73,18 +74,22 @@ class InfoCommand < HammerCLIKatello::InfoCommand
end

def extend_data(data)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you may want to do a bit of refactoring on this method to reduce cyclomatic complexity for rubocop

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if we can do too much to reduce this, since it is not a method that we define, but part of the general framework.

I would be tempted to either:

  1. disable the cop on that specific method instance
  2. not use the method

I prefer 1 as I really wanted to keep the behavior consistent with the other fields.

Thoughts?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would try to separate some of this logic into a method, like setup_sync_state does.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @akofink ! updated.

data["_redhat_repo"] = data["product_type"] == "redhat" ? _("yes") : _("no")
data["_publish_via_http"] = data["unprotected"] ? _("yes") : _("no")

if data["content_type"] == "yum" && data["gpg_key"]
data["gpg_key_name"] = data["gpg_key"]["name"]
end

setup_sync_state(data)
setup_booleans(data)
setup_content_counts(data) if data["content_counts"]
data
end

def setup_booleans(data)
data["_redhat_repo"] = data["product_type"] == "redhat" ? _("yes") : _("no")
data["_publish_via_http"] = data["unprotected"] ? _("yes") : _("no")
data["_mirror_on_sync"] = data["mirror_on_sync"] ? _("yes") : _("no")
end

def setup_sync_state(data)
if data['last_sync']
data['_sync_state'] = get_sync_status(data["last_sync"]["result"])
Expand Down Expand Up @@ -113,14 +118,9 @@ def setup_content_counts(data)

def get_sync_status(state)
sync_states = {
"failed" => _("Failed"),
"success" => _("Success"),
"finished" => _("Finished"),
"error" => _("Error"),
"running" => _("Running"),
"waiting" => _("Waiting"),
"canceled" => _("Canceled"),
"not_synced" => _("Not Synced")
"failed" => _("Failed"), "success" => _("Success"), "finished" => _("Finished"),
"error" => _("Error"), "running" => _("Running"), "waiting" => _("Waiting"),
"canceled" => _("Canceled"), "not_synced" => _("Not Synced")
}
sync_states[state]
end
Expand Down