Sha256: 1ba1145f2a01079327523852b7a11c31d77cad7489192bc30d1a727fa51a223a

Contents?: true

Size: 1.43 KB

Versions: 29

Compression:

Stored size: 1.43 KB

Contents

require_relative '../common'

module Kontena::Cli::Stacks::Registry
  class PushCommand < Kontena::Command
    include Kontena::Cli::Common
    include Kontena::Cli::Stacks::Common

    banner "Pushes (uploads) a stack to the stack registry"

    parameter "[FILE]", "Kontena stack file path", default: "kontena.yml", attribute_name: :source

    requires_current_account_token

    option '--dry-run', :flag, "Do not perform any uploading", hidden: true

    def includes_local_dependencies?(dependencies = loader.dependencies)
      return false if dependencies.nil?
      dependencies.any? { |dep| Kontena::Cli::Stacks::YAML::StackFileLoader.for(dep['stack']).origin == 'file' || includes_local_dependencies(dep['depends']) }
    end

    def includes_local_extends?
      loader.yaml.fetch('services', {}).any? { |_, svc| svc.key?('extends') && svc['extends'].key?('file') }
    end

    def execute
      exit_with_error "Can only perform push from local files" unless loader.origin == "file"
      exit_with_error "Stack file contains dependencies to local files" if includes_local_dependencies?
      exit_with_error "Stack file has services that extend from local files" if includes_local_extends?

      spinner("Pushing #{pastel.cyan(source)} to stack registry as #{loader.stack_name}") do
        unless dry_run?
          stacks_client.push(
            loader.stack_name,
            loader.content
          )
        end
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 2 rubygems

Version Path
krates-1.7.11 lib/kontena/cli/stacks/registry/push_command.rb
krates-1.7.10 lib/kontena/cli/stacks/registry/push_command.rb
krates-1.7.9 lib/kontena/cli/stacks/registry/push_command.rb
krates-1.7.8 lib/kontena/cli/stacks/registry/push_command.rb
krates-1.7.7 lib/kontena/cli/stacks/registry/push_command.rb
krates-1.7.6 lib/kontena/cli/stacks/registry/push_command.rb
krates-1.7.5 lib/kontena/cli/stacks/registry/push_command.rb
krates-1.7.4 lib/kontena/cli/stacks/registry/push_command.rb
krates-1.7.3 lib/kontena/cli/stacks/registry/push_command.rb
krates-1.7.2 lib/kontena/cli/stacks/registry/push_command.rb
krates-1.7.1 lib/kontena/cli/stacks/registry/push_command.rb
krates-1.7.0 lib/kontena/cli/stacks/registry/push_command.rb
krates-1.6.9 lib/kontena/cli/stacks/registry/push_command.rb
krates-1.6.8 lib/kontena/cli/stacks/registry/push_command.rb
krates-1.6.7 lib/kontena/cli/stacks/registry/push_command.rb
krates-1.6.6 lib/kontena/cli/stacks/registry/push_command.rb
krates-1.6.5 lib/kontena/cli/stacks/registry/push_command.rb
krates-1.6.4 lib/kontena/cli/stacks/registry/push_command.rb
krates-1.6.3 lib/kontena/cli/stacks/registry/push_command.rb
krates-1.6.2 lib/kontena/cli/stacks/registry/push_command.rb