require "./src/source_handler"
require "kubernetes"

# Initialize the Kubernetes client
k8s = ContainerMom::K8sClientWrapper.new

# Start watching for ContainerDeployment resources
Kubernetes.watch("containerdeployments") do |event|
  resource = Kubernetes::Resource(ContainerMom::Types::ContainerDeploymentSpec).from_json(event.raw_object.to_json)
  
  begin
    ContainerMom::SourceHandler.handle(k8s, resource)
  rescue ex
    puts "Error handling resource: #{ex.message}"
  end
end
