module EtcdCookbook
  class EtcdServiceManagerDocker < EtcdServiceBase
    resource_name :etcd_service_manager_docker

    property :repo, String, default: 'quay.io/coreos/etcd'
    property :tag, default: lazy { "v#{version}" }
    property :version, default: '3.2.6', desired_state: false
    property :container_name, String, default: lazy { |n| "etcd-#{n.node_name}" }, desired_state: false
    property :port, default: ['2379/tcp4:2379', '2380/tcp4:2380']
    property :network_mode, String, default: 'host'

    action :start do
      docker_container new_resource.container_name do
        repo new_resource.repo
        tag new_resource.tag
        command etcd_daemon_opts.join(' ').strip
        port new_resource.port
        network_mode new_resource.network_mode
        action :run
      end
    end

    action :stop do
      docker_container container_name do
        action [:stop, :delete]
      end
    end

    action :restart do
      action_stop
      action_start
    end

    action_class do
      include EtcdHelpers::Service
    end
  end
end

module EtcdCookbook
  class EtcdServiceManagerDocker < EtcdServiceBase
    resource_name :etcd_service_manager_docker

    property :repo, String, default: 'quay.io/coreos/etcd'
    property :tag, default: lazy { "v#{version}" }
    property :version, default: '3.2.6', desired_state: false
    property :container_name, String, default: lazy { |n| "etcd-#{n.node_name}" }, desired_state: false
    property :port, default: ['2379/tcp4:2379', '2380/tcp4:2380']
    property :network_mode, String, default: 'host'

    action :start do
      docker_container new_resource.container_name do
        repo new_resource.repo
        tag new_resource.tag
        command "etcd #{etcd_daemon_opts.join(' ').strip}"
        port new_resource.port
        network_mode new_resource.network_mode
        action :run
      end
    end

    action :stop do
      docker_container container_name do
        action [:stop, :delete]
      end
    end

    action :restart do
      action_stop
      action_start
    end

    action_class do
      include EtcdHelpers::Service
    end
  end
end

Fix the etcd command to include the binary name in etcd_service_manage_docker
Fix the etcd command to include the binary name in etcd_service_manage_docker

Signed-off-by: Tim Smith <764ef62106582a09ed09dfa0b6bff7c05fd7d1e4@chef.io>
