Sha256: a167750e5d0efb8e57c88cca12ee4010183d7926d4c813d77a5faadd4f230dba

Contents?: true

Size: 559 Bytes

Versions: 3

Compression:

Stored size: 559 Bytes

Contents

require "milc/dsl"

require 'json'

module Milc::Dsl
  module Gcloud

    def gcloud(cmd, &block)
      execute(build_gcloud_command(cmd), returns: :none, logging: :both, &block)
    end

    def json_gcloud(cmd)
      r = execute(build_gcloud_command(cmd + " --format json"), returns: :stdout, logging: :stderr)
      res = r.nil? ? nil : JSON.parse(r)
      block_given? ? yield(res) : res
    end

    def build_gcloud_command(cmd)
      r = "gcloud #{cmd}"
      r << " --project #{project}" unless cmd =~ /\s\-\-project[\s\=]/
      r
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
milc-0.2.2 lib/milc/dsl/gcloud.rb
milc-0.2.1 lib/milc/dsl/gcloud.rb
milc-0.2.0 lib/milc/dsl/gcloud.rb