Sha256: 7c87862a8eed4b83dd32eb3d3bb01c425ad441471beecdd99dd47107a85c3bd0
Contents?: true
Size: 580 Bytes
Versions: 11
Compression:
Stored size: 580 Bytes
Contents
require 'json' class KubernetesAnnotationsTagAppender attr_reader :annotations def initialize(annotations) @annotations = annotations end def append(tag, data, container_name) matches = annotations.select do | annotation | json = data[annotation] || "[]" JSON.parse(json)&.include? container_name end # Don't re-add tags if they're already present: orig_tags = tag.split(".") # Unique with order preservation: uniqs = orig_tags + ["annotated"] + matches.reject { |x| orig_tags.include? x } return uniqs.join(".") end end
Version data entries
11 entries across 11 versions & 1 rubygems