require "kubernetes"

module ContainerMom
  # Source credentials structure
  struct SourceCredentials
    include Kubernetes::Serializable

    field username : String
    field password : String
  end

  # Source configuration structure
  struct SourceConfig
    include Kubernetes::Serializable

    field type : String
    field url : String
    field credentials : SourceCredentials?
  end

  # Define the ContainerDeployment spec structure
  struct ContainerDeploymentSpec
    include Kubernetes::Serializable

    field regions : Array(String)
    field resources : Hash(String, String)?
    field domain : Hash(String, String)?
    field billing : Hash(String, String)?
    field source : SourceConfig
  end

  # Define our custom resources
  Kubernetes.define_resource "secrets",
    group: "",
    type: Kubernetes::Resource(JSON::Any),
    kind: "Secret",
    version: "v1"

  Kubernetes.define_resource "configmaps",
    group: "",
    type: Kubernetes::Resource(JSON::Any),
    kind: "ConfigMap",
    version: "v1"

  Kubernetes.define_resource "jobs",
    group: "batch",
    type: Kubernetes::Resource(JSON::Any),
    kind: "Job",
    version: "v1"

  Kubernetes.define_resource "deployments",
    group: "apps",
    type: Kubernetes::Resource(JSON::Any),
    kind: "Deployment",
    version: "v1"

  Kubernetes.define_resource "services",
    group: "",
    type: Kubernetes::Resource(JSON::Any),
    kind: "Service",
    version: "v1"

  Kubernetes.define_resource "ingresses",
    group: "networking.k8s.io",
    type: Kubernetes::Resource(JSON::Any),
    kind: "Ingress",
    version: "v1"

  # Define our custom ContainerDeployment resource
  Kubernetes.define_resource "containerdeployments",
    group: "app.container.mom",
    type: Kubernetes::Resource(ContainerDeploymentSpec),
    kind: "ContainerDeployment",
    version: "v1alpha1"
end
