<commit_before>require "./concerns/resource"
require "./shared/network_status"

class Psykube::Kubernetes::Service
  include Resource
  definition("v1", "Service", {
    spec:   Spec?,
    status: {type: Shared::NetworkStatus, nilable: true, clean: true},
  })

  def initialize(name : String)
    initialize
    metadata.name = name
    spec = Spec.new
    spec.selector["app"] = name
    @spec = spec
  end

  def initialize(name : String, ports : Hash(String, UInt16))
    initialize(name)
    spec = Spec.new
    ports.each do |name, port|
      spec.ports.push(Spec::Port.new(name, port))
    end
    @spec = spec
  end

  def initialize(name : String, ports : Nil)
    initialize(name)
  end
end

require "./service/*"<commit_msg>fix service labels<commit_after>require "./concerns/resource"
require "./shared/network_status"

class Psykube::Kubernetes::Service
  include Resource
  definition("v1", "Service", {
    spec:   Spec?,
    status: {type: Shared::NetworkStatus, nilable: true, clean: true},
  })

  def initialize(name : String)
    previous_def(name)
    (metadata.labels ||= {} of String => String)["service"] = name
    spec = Spec.new
    spec.selector["app"] = name
    @spec = spec
  end

  def initialize(name : String, ports : Hash(String, UInt16))
    initialize(name)
    if spec = self.spec
      ports.each do |name, port|
        spec.ports.push(Spec::Port.new(name, port))
      end
    end
  end

  def initialize(name : String, ports : Nil)
    initialize(name)
  end
end

require "./service/*"
{'fraction_non_alphanumeric': 0.1354712041884817, 'fraction_numerical': 0.003926701570680628, 'mean_word_length': 3.2472222222222222, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5304603', 'n_tokens_mistral': 492, 'n_tokens_neox': 479, 'n_words': 126}