Sha256: 49583767e53f2d0692b6fda33e4f57a7b47439c3b7daca38ca7096267a9c067e

Contents?: true

Size: 1.7 KB

Versions: 1

Compression:

Stored size: 1.7 KB

Contents

require 'ey-core/cli/subcommand'
require 'ey-core/cli/helpers/chef'
require 'ey-core/cli/helpers/archive'

module Ey
  module Core
    module Cli
      module Recipes
        class Upload < Ey::Core::Cli::Subcommand
          include Ey::Core::Cli::Helpers::Archive
          include Ey::Core::Cli::Helpers::Chef

          title "upload"
          summary "Upload custom recipes to an environment"

          option :environment,
            short: "e",
            long: "environment",
            description: "Environment that will receive the recipes.",
            argument: "environment"

          option :account,
            short: "c",
            long: "account",
            description: "Name of the account in which the environment can be found.",
            argument: "account"

          option :file,
            short: "f",
            long: "file",
            description: "Path to recipes",
            argument: "path"

          switch :apply,
            short: "a",
            long: "apply",
            description: "Apply the recipes immediately after they are uploaded"

          def handle
            operator, environment = core_operator_and_environment_for(options)
            path = option(:file) || "cookbooks/"

            puts "Uploading custom recipes for #{environment.name}".green

            begin
              upload_recipes(environment, path)
              puts "Uploading custom recipes complete".green
            rescue => e
              puts e.message
              abort "There was a problem uploading the recipes".red
            end

            if switch_active?(:apply)
              run_chef("main", environment)
            end
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ey-core-3.1.9 lib/ey-core/cli/recipes/upload.rb