Sha256: 69bc8566a465eb149312aa3710365f8dee085ab110d6f83ffa66a04f5fd3ef98

Contents?: true

Size: 1.28 KB

Versions: 6

Compression:

Stored size: 1.28 KB

Contents

module Shipit
  class DeploySpec
    module KubernetesDiscovery
      def discover_deploy_steps
        discover_kubernetes || super
      end

      def discover_rollback_steps
        discover_kubernetes || super
      end

      def discover_task_definitions
        if kube_config.present?
          {
            'restart' => {
              'action' => "Restart application",
              'description' => "Simulates a rollout of Kubernetes deployments by using kubernetes-restart utility",
              'steps' => [kubernetes_restart_cmd],
            },
          }
        else
          super
        end
      end

      private

      def discover_kubernetes
        return unless kube_config.present?

        cmd = ["kubernetes-deploy"]
        if kube_config['template_dir']
          cmd << '--template-dir'
          cmd << kube_config['template_dir']
        end

        cmd << kube_config.fetch('namespace')
        cmd << kube_config.fetch('context')

        [Shellwords.join(cmd)]
      end

      def kube_config
        @kube_config ||= config('kubernetes') || {}
      end

      def kubernetes_restart_cmd
        Shellwords.join([
          "kubernetes-restart",
          kube_config.fetch('namespace'),
          kube_config.fetch('context'),
        ])
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
shipit-engine-0.20.1 app/models/shipit/deploy_spec/kubernetes_discovery.rb
shipit-engine-0.20.0 app/models/shipit/deploy_spec/kubernetes_discovery.rb
shipit-engine-0.19.0 app/models/shipit/deploy_spec/kubernetes_discovery.rb
shipit-engine-0.18.1 app/models/shipit/deploy_spec/kubernetes_discovery.rb
shipit-engine-0.18.0 app/models/shipit/deploy_spec/kubernetes_discovery.rb
shipit-engine-0.17.0 app/models/shipit/deploy_spec/kubernetes_discovery.rb