Skip to content

Commit

Permalink
Backport of Tag mapping in Graph refresh
Browse files Browse the repository at this point in the history
ManageIQ#16734

plus additional methods required
  • Loading branch information
Julian Cheal committed Feb 28, 2018
1 parent 79fdd0b commit 1a02c5b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/models/classification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ class Classification < ApplicationRecord
scope :read_only, -> { where :read_only => true }
scope :writeable, -> { where :read_only => false }

scope :is_category, -> { where(:parent_id => 0) }
scope :is_entry, -> { where.not(:parent_id => 0) }

DEFAULT_NAMESPACE = "/managed"

default_value_for :read_only, false
Expand Down
1 change: 1 addition & 0 deletions app/models/container_label_tag_mapping.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class ContainerLabelTagMapping < ApplicationRecord
#
# All involved tags must also have a Classification.

TAG_PREFIXES = ['/managed/amazon:', '/managed/kubernetes:'].freeze
AUTOTAG_PREFIX = "kubernetes".freeze

MAPPABLE_ENTITIES = [
Expand Down
7 changes: 7 additions & 0 deletions app/models/tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ class Tag < ApplicationRecord

before_destroy :remove_from_managed_filters

# Note those scopes exclude Tags that don't have a Classification.
scope :visible, -> { joins(:classification).merge(Classification.visible) }
scope :read_only, -> { joins(:classification).merge(Classification.read_only) }
scope :writable, -> { joins(:classification).merge(Classification.writable) }
scope :is_category, -> { joins(:classification).merge(Classification.is_category) }
scope :is_entry, -> { joins(:classification).merge(Classification.is_entry) }

def self.list(object, options = {})
ns = get_namespace(options)
if ns[0..7] == "/virtual"
Expand Down

0 comments on commit 1a02c5b

Please sign in to comment.