Sha256: a8dace8745e2df5ac5d7024d0d10b6f5a4eaac579797d7a8a61ed90900804dc8

Contents?: true

Size: 386 Bytes

Versions: 3

Compression:

Stored size: 386 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

    return ([tag] + matches).join(".")
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fluent-plugin-append-kubernetes-annotations-to-tag-0.1.0.pre.4 lib/kubernetes_annotations_tag_appender.rb
fluent-plugin-append-kubernetes-annotations-to-tag-0.1.0.pre.3 lib/kubernetes_annotations_tag_appender.rb
fluent-plugin-append-kubernetes-annotations-to-tag-0.1.0.pre.2 lib/kubernetes_annotations_tag_appender.rb