Sha256: 8f792391e6cbd62d7bd05b6d862ea6375cbefc1614757c7fb2a59cd89cf683f6

Contents?: true

Size: 966 Bytes

Versions: 34

Compression:

Stored size: 966 Bytes

Contents

module Kontena::Cli::Grids::TrustedSubnets
  class RemoveCommand < Kontena::Command
    include Kontena::Cli::Common
    include Kontena::Cli::GridOptions

    parameter "SUBNET ...", "Trusted subnet", attribute_name: :subnets
    option "--force", :flag, "Force remove", default: false, attribute_name: :forced

    requires_current_master

    def execute
      subnets.each do |subnet|
        grid = client.get("grids/#{current_grid}")
        confirm_command(subnet) unless forced?
        trusted_subnets = grid['trusted_subnets'] || []
        unless trusted_subnets.delete(subnet)
          exit_with_error("Grid #{pastel.cyan(current_grid)} does not have trusted subnet #{pastel.cyan(subnet)}")
        end
        data = {trusted_subnets: trusted_subnets}
        spinner "Removing trusted subnet #{pastel.cyan(subnet)} from #{pastel.cyan(current_grid)} grid " do
          client.put("grids/#{current_grid}", data)
        end
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 2 rubygems

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