Sha256: 8ebd070c99d38fe3ccdfca4a67fcfd037866eca84e6ce3d5d8fcce1b250410f9

Contents?: true

Size: 1.38 KB

Versions: 17

Compression:

Stored size: 1.38 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"

    include Kontena::Cli::Stacks::Common::StackFileOrNameParam
    include Kontena::Cli::Stacks::Common::StackValuesFromOption

    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?
      stack.fetch(:services) { {} }.any? { |svc| svc['extends'] && svc[:extends]['file'] }
    end

    def execute
      set_env_variables(stack_name, 'validate', 'validate-platform')

      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 stacks registry as #{loader.stack_name}") do
        stacks_client.push(stack_name, loader.stack_name.version, loader.content) unless dry_run?
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
kontena-cli-1.4.2 lib/kontena/cli/stacks/registry/push_command.rb
kontena-cli-1.4.2.rc1 lib/kontena/cli/stacks/registry/push_command.rb
kontena-cli-1.4.2.pre1 lib/kontena/cli/stacks/registry/push_command.rb
kontena-cli-1.4.1 lib/kontena/cli/stacks/registry/push_command.rb
kontena-cli-1.4.1.rc1 lib/kontena/cli/stacks/registry/push_command.rb
kontena-cli-1.4.1.pre1 lib/kontena/cli/stacks/registry/push_command.rb
kontena-cli-1.4.0 lib/kontena/cli/stacks/registry/push_command.rb
kontena-cli-1.4.0.rc2 lib/kontena/cli/stacks/registry/push_command.rb
kontena-cli-1.4.0.rc1 lib/kontena/cli/stacks/registry/push_command.rb
kontena-cli-1.4.0.pre14 lib/kontena/cli/stacks/registry/push_command.rb
kontena-cli-1.4.0.pre13 lib/kontena/cli/stacks/registry/push_command.rb
kontena-cli-1.4.0.pre12 lib/kontena/cli/stacks/registry/push_command.rb
kontena-cli-1.4.0.pre11 lib/kontena/cli/stacks/registry/push_command.rb
kontena-cli-1.4.0.pre10 lib/kontena/cli/stacks/registry/push_command.rb
kontena-cli-1.4.0.pre9 lib/kontena/cli/stacks/registry/push_command.rb
kontena-cli-1.4.0.pre8 lib/kontena/cli/stacks/registry/push_command.rb
kontena-cli-1.4.0.pre7 lib/kontena/cli/stacks/registry/push_command.rb