
# This file is automatically generated by puppet-swagger-generator and
# any manual changes are likely to be clobbered when the files
# are regenerated.

require_relative '../../../puppet_x/puppetlabs/kubernetes/provider'

Puppet::Type.type(:kubernetes_container).provide(:swagger, :parent => PuppetX::Puppetlabs::Kubernetes::Provider) do

  mk_resource_methods

  def self.instance_to_hash(instance)
    {
    ensure: :present,
    name: instance.metadata.name,
    
      
        
        name: instance.name.respond_to?(:to_hash) ? instance.name.to_hash : instance.name,
        
      
    
      
        
        image: instance.image.respond_to?(:to_hash) ? instance.image.to_hash : instance.image,
        
      
    
      
        
        command: hash_arrays(instance.command),
        
      
    
      
        
        args: hash_arrays(instance.args),
        
      
    
      
        
        working_dir: instance.workingDir.respond_to?(:to_hash) ? instance.workingDir.to_hash : instance.workingDir,
        
      
    
      
        
        ports: hash_arrays(instance.ports),
        
      
    
      
        
        env_from: hash_arrays(instance.envFrom),
        
      
    
      
        
        env: hash_arrays(instance.env),
        
      
    
      
        
        resources: instance.resources.respond_to?(:to_hash) ? instance.resources.to_hash : instance.resources,
        
      
    
      
        
        volume_mounts: hash_arrays(instance.volumeMounts),
        
      
    
      
        
        liveness_probe: instance.livenessProbe.respond_to?(:to_hash) ? instance.livenessProbe.to_hash : instance.livenessProbe,
        
      
    
      
        
        readiness_probe: instance.readinessProbe.respond_to?(:to_hash) ? instance.readinessProbe.to_hash : instance.readinessProbe,
        
      
    
      
        
        lifecycle: instance.lifecycle.respond_to?(:to_hash) ? instance.lifecycle.to_hash : instance.lifecycle,
        
      
    
      
        
        termination_message_path: instance.terminationMessagePath.respond_to?(:to_hash) ? instance.terminationMessagePath.to_hash : instance.terminationMessagePath,
        
      
    
      
        
        termination_message_policy: instance.terminationMessagePolicy.respond_to?(:to_hash) ? instance.terminationMessagePolicy.to_hash : instance.terminationMessagePolicy,
        
      
    
      
        
        image_pull_policy: instance.imagePullPolicy.respond_to?(:to_hash) ? instance.imagePullPolicy.to_hash : instance.imagePullPolicy,
        
      
    
      
        
        security_context: instance.securityContext.respond_to?(:to_hash) ? instance.securityContext.to_hash : instance.securityContext,
        
      
    
      
        
        stdin: instance.stdin.respond_to?(:to_hash) ? instance.stdin.to_hash : instance.stdin,
        
      
    
      
        
        stdin_once: instance.stdinOnce.respond_to?(:to_hash) ? instance.stdinOnce.to_hash : instance.stdinOnce,
        
      
    
      
        
        tty: instance.tty.respond_to?(:to_hash) ? instance.tty.to_hash : instance.tty,
        
      
    
    object: instance,
    }
  end

  def create
    Puppet.info("Creating kubernetes_container #{name}")
    create_instance_of('container', name, build_params)
  end

  def flush
   unless @property_hash.empty?
     unless resource[:ensure] == :absent
        flush_instance_of('container', name, @property_hash[:object], build_params)
      end
    end
  end

  def destroy
    Puppet.info("Deleting kubernetes_container #{name}")
    destroy_instance_of('container', name)
    @property_hash[:ensure] = :absent
  end

  private
  def self.list_instances
    list_instances_of('container')
  end

  def build_params
    params = {
    
      
        name: resource[:name],
      
    
      
        image: resource[:image],
      
    
      
        command: resource[:command],
      
    
      
        args: resource[:args],
      
    
      
        workingDir: resource[:working_dir],
      
    
      
        ports: resource[:ports],
      
    
      
        envFrom: resource[:env_from],
      
    
      
        env: resource[:env],
      
    
      
        resources: resource[:resources],
      
    
      
        volumeMounts: resource[:volume_mounts],
      
    
      
        livenessProbe: resource[:liveness_probe],
      
    
      
        readinessProbe: resource[:readiness_probe],
      
    
      
        lifecycle: resource[:lifecycle],
      
    
      
        terminationMessagePath: resource[:termination_message_path],
      
    
      
        terminationMessagePolicy: resource[:termination_message_policy],
      
    
      
        imagePullPolicy: resource[:image_pull_policy],
      
    
      
        securityContext: resource[:security_context],
      
    
      
        stdin: resource[:stdin],
      
    
      
        stdinOnce: resource[:stdin_once],
      
    
      
        tty: resource[:tty],
      
    
    }
    params.delete_if { |key, value| value.nil? }
    params
  end
end
