Sha256: 9e5aeeb4f5b1e2452f7568594e6c1adac3077e827275d3ccd4b1201e67ff49e3

Contents?: true

Size: 1.51 KB

Versions: 16

Compression:

Stored size: 1.51 KB

Contents

require "pretty_table"
require "awesome_print"
require_relative "logging"

module AwsPocketknife
  module Common
    module Utils
      #include AwsPocketknife::Common::Logging

      def ec2_client
        @ec2_client ||= AwsPocketknife.ec2_client
      end

      def ecs_client
        @ecs_client ||= AwsPocketknife.ecs_client
      end

      def iam_client
        @iam_client ||= AwsPocketknife.iam_client
      end

      def route53_client
        @route53_client ||= AwsPocketknife.route53_client
      end

      def rds_client
        @rds_client ||= AwsPocketknife.rds_client
      end

      def elb_client
        @elb_client ||= AwsPocketknife.elb_client
      end

      def asg_client
        @asg_client ||= AwsPocketknife.asg_client
      end

      def cloudwatch_logs_client
        @cloudwatch_logs_client ||= AwsPocketknife.cloudwatch_logs_client
      end

      def elastic_beanstalk_client
        @elastic_beanstalk_client ||= AwsPocketknife.elastic_beanstalk_client
      end

      def pretty_table(headers: [], data: [])
        puts PrettyTable.new(data, headers).to_s
      end

      # https://github.com/michaeldv/awesome_print
      def nice_print(object: nil)
        ap object
      end

      def get_tag_value(tags: [], tag_key: "")
        unless tags.empty? or tag_key.length == 0
          tag =  tags.select { |tag| tag.key == tag_key }
          return tag[0].value if tag.length == 1
          return "" if tag.length == 0
        else
          return ""
        end
      end

    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
aws_pocketknife-0.1.26 lib/aws_pocketknife/common/utils.rb
aws_pocketknife-0.1.25 lib/aws_pocketknife/common/utils.rb
aws_pocketknife-0.1.24 lib/aws_pocketknife/common/utils.rb
aws_pocketknife-0.1.23 lib/aws_pocketknife/common/utils.rb
aws_pocketknife-0.1.21 lib/aws_pocketknife/common/utils.rb
aws_pocketknife-0.1.20 lib/aws_pocketknife/common/utils.rb
aws_pocketknife-0.1.19 lib/aws_pocketknife/common/utils.rb
aws_pocketknife-0.1.18 lib/aws_pocketknife/common/utils.rb
aws_pocketknife-0.1.17 lib/aws_pocketknife/common/utils.rb
aws_pocketknife-0.1.16 lib/aws_pocketknife/common/utils.rb
aws_pocketknife-0.1.15 lib/aws_pocketknife/common/utils.rb
aws_pocketknife-0.1.14 lib/aws_pocketknife/common/utils.rb
aws_pocketknife-0.1.13 lib/aws_pocketknife/common/utils.rb
aws_pocketknife-0.1.12 lib/aws_pocketknife/common/utils.rb
aws_pocketknife-0.1.11 lib/aws_pocketknife/common/utils.rb
aws_pocketknife-0.1.10 lib/aws_pocketknife/common/utils.rb