gclouder 0.1.8 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/assets/arguments/functions.yml +30 -0
 - data/lib/gclouder/gsutil.rb +2 -2
 - data/lib/gclouder/resource.rb +1 -1
 - data/lib/gclouder/resources/functions/function.rb +79 -0
 - data/lib/gclouder/resources/storage/buckets.rb +3 -4
 - data/lib/gclouder/resources/storage/notifications.rb +7 -2
 - data/lib/gclouder/version.rb +1 -1
 - data/lib/gclouder.rb +8 -0
 - metadata +4 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 2c516273470e35539fa6a910424577e69a14d5aa
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 9b83e1ac431a504b01b6ae00fb1e9651c3def051
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 8b2d0b042a9c2bd01d772c3a04626043c3f2cb1eb1a1e1537ef070d6203d1cf4f52ed2409bc872577c2eaebb95d67806f0ffb73c580116673fd16ce5b07b64dc
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 22107c3383753a45030193eb6ce9b9a64f2a7928d0d7ca93cf540aaa7fc0c556a98fd9ffa6c143d4f70f0b587bcd4f235dc73d8f0a967451b24a85887bd0f145
         
     | 
| 
         @@ -0,0 +1,30 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ---
         
     | 
| 
      
 2 
     | 
    
         
            +
            name:
         
     | 
| 
      
 3 
     | 
    
         
            +
              type: String
         
     | 
| 
      
 4 
     | 
    
         
            +
              required: true
         
     | 
| 
      
 5 
     | 
    
         
            +
            stage_bucket:
         
     | 
| 
      
 6 
     | 
    
         
            +
              type: String
         
     | 
| 
      
 7 
     | 
    
         
            +
            trigger_topic:
         
     | 
| 
      
 8 
     | 
    
         
            +
              type: String
         
     | 
| 
      
 9 
     | 
    
         
            +
            trigger_http:
         
     | 
| 
      
 10 
     | 
    
         
            +
              type: Boolean
         
     | 
| 
      
 11 
     | 
    
         
            +
            local_path:
         
     | 
| 
      
 12 
     | 
    
         
            +
              type: String
         
     | 
| 
      
 13 
     | 
    
         
            +
            source_url:
         
     | 
| 
      
 14 
     | 
    
         
            +
              type: String
         
     | 
| 
      
 15 
     | 
    
         
            +
            source_path:
         
     | 
| 
      
 16 
     | 
    
         
            +
              type: String
         
     | 
| 
      
 17 
     | 
    
         
            +
            source_branch:
         
     | 
| 
      
 18 
     | 
    
         
            +
              type: String
         
     | 
| 
      
 19 
     | 
    
         
            +
            source_tag:
         
     | 
| 
      
 20 
     | 
    
         
            +
              type: String
         
     | 
| 
      
 21 
     | 
    
         
            +
            source_revision:
         
     | 
| 
      
 22 
     | 
    
         
            +
              type: String
         
     | 
| 
      
 23 
     | 
    
         
            +
            memory:
         
     | 
| 
      
 24 
     | 
    
         
            +
              type: String
         
     | 
| 
      
 25 
     | 
    
         
            +
            timeout:
         
     | 
| 
      
 26 
     | 
    
         
            +
              type: String
         
     | 
| 
      
 27 
     | 
    
         
            +
            include_ignored_files:
         
     | 
| 
      
 28 
     | 
    
         
            +
              type: String
         
     | 
| 
      
 29 
     | 
    
         
            +
            entry-point:
         
     | 
| 
      
 30 
     | 
    
         
            +
              type: String
         
     | 
    
        data/lib/gclouder/gsutil.rb
    CHANGED
    
    | 
         @@ -11,7 +11,7 @@ module GClouder 
     | 
|
| 
       11 
11 
     | 
    
         
             
                end
         
     | 
| 
       12 
12 
     | 
    
         | 
| 
       13 
13 
     | 
    
         
             
                def gsutil(command, args, force: false)
         
     | 
| 
       14 
     | 
    
         
            -
                  info "# gsutil #{command}  
     | 
| 
      
 14 
     | 
    
         
            +
                  info "# gsutil #{command} #{args}" if cli_args[:debug]
         
     | 
| 
       15 
15 
     | 
    
         | 
| 
       16 
16 
     | 
    
         
             
                  return if cli_args[:dry_run] && !force
         
     | 
| 
       17 
17 
     | 
    
         | 
| 
         @@ -19,7 +19,7 @@ module GClouder 
     | 
|
| 
       19 
19 
     | 
    
         
             
                end
         
     | 
| 
       20 
20 
     | 
    
         | 
| 
       21 
21 
     | 
    
         
             
                def gsutil_exec(command, args)
         
     | 
| 
       22 
     | 
    
         
            -
                  shell("gsutil #{command}  
     | 
| 
      
 22 
     | 
    
         
            +
                  shell("gsutil #{command} #{args}")
         
     | 
| 
       23 
23 
     | 
    
         
             
                end
         
     | 
| 
       24 
24 
     | 
    
         
             
              end
         
     | 
| 
       25 
25 
     | 
    
         
             
            end
         
     | 
    
        data/lib/gclouder/resource.rb
    CHANGED
    
    | 
         @@ -11,7 +11,7 @@ module GClouder 
     | 
|
| 
       11 
11 
     | 
    
         
             
                  send action, "#{name} #{extra_info}", indent: indent
         
     | 
| 
       12 
12 
     | 
    
         
             
                end
         
     | 
| 
       13 
13 
     | 
    
         | 
| 
       14 
     | 
    
         
            -
                def self.resource?(resource, name, args = nil, filter_key: "name", filter: "#{filter_key} ~ ^#{name}$", project_id: nil, silent: false, extra_info: nil, indent: 3)
         
     | 
| 
      
 14 
     | 
    
         
            +
                def self.resource?(resource, name, args = nil, filter_key: "name", filter_value: nil, filter: "#{filter_key} ~ ^#{filter_value || name}$", project_id: nil, silent: false, extra_info: nil, indent: 3)
         
     | 
| 
       15 
15 
     | 
    
         
             
                  exists = \
         
     | 
| 
       16 
16 
     | 
    
         
             
                    gcloud("#{resource} list --filter '#{filter}' #{args} | jq '. | length'", force: true, project_id: project_id) > 0
         
     | 
| 
       17 
17 
     | 
    
         | 
| 
         @@ -0,0 +1,79 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            #!/usr/bin/env ruby
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module GClouder
         
     | 
| 
      
 4 
     | 
    
         
            +
              module Resources
         
     | 
| 
      
 5 
     | 
    
         
            +
                module Functions
         
     | 
| 
      
 6 
     | 
    
         
            +
                  module Function
         
     | 
| 
      
 7 
     | 
    
         
            +
                    include GClouder::Config::CLIArgs
         
     | 
| 
      
 8 
     | 
    
         
            +
                    include GClouder::Logging
         
     | 
| 
      
 9 
     | 
    
         
            +
                    include GClouder::Resource::Cleaner
         
     | 
| 
      
 10 
     | 
    
         
            +
                    include GClouder::Config::Project
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                    def self.header(stage = :ensure)
         
     | 
| 
      
 13 
     | 
    
         
            +
                      info "[#{stage}] functions / function", indent: 1, title: true
         
     | 
| 
      
 14 
     | 
    
         
            +
                    end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                    def self.ensure
         
     | 
| 
      
 17 
     | 
    
         
            +
                      return if Local.list.empty?
         
     | 
| 
      
 18 
     | 
    
         
            +
                      header
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
                      Local.list.each do |region, functions|
         
     | 
| 
      
 21 
     | 
    
         
            +
                        info region, indent: 2, heading: true
         
     | 
| 
      
 22 
     | 
    
         
            +
                        info
         
     | 
| 
      
 23 
     | 
    
         
            +
                        functions.each do |function|
         
     | 
| 
      
 24 
     | 
    
         
            +
                          Function.ensure(region, function)
         
     | 
| 
      
 25 
     | 
    
         
            +
                        end
         
     | 
| 
      
 26 
     | 
    
         
            +
                      end
         
     | 
| 
      
 27 
     | 
    
         
            +
                    end
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
                    def self.validate
         
     | 
| 
      
 30 
     | 
    
         
            +
                      return if Local.list.empty?
         
     | 
| 
      
 31 
     | 
    
         
            +
                      header :validate
         
     | 
| 
      
 32 
     | 
    
         
            +
                      Local.validate
         
     | 
| 
      
 33 
     | 
    
         
            +
                    end
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
                    module Local
         
     | 
| 
      
 36 
     | 
    
         
            +
                      include GClouder::Config::CLIArgs
         
     | 
| 
      
 37 
     | 
    
         
            +
                      include GClouder::Config::Project
         
     | 
| 
      
 38 
     | 
    
         
            +
                      include GClouder::Logging
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
                      def self.validate
         
     | 
| 
      
 41 
     | 
    
         
            +
                        Resources::Validate::Region.instances(
         
     | 
| 
      
 42 
     | 
    
         
            +
                          list,
         
     | 
| 
      
 43 
     | 
    
         
            +
                          required_keys:  GClouder::Config::Arguments.required(%w(functions)),
         
     | 
| 
      
 44 
     | 
    
         
            +
                          permitted_keys: GClouder::Config::Arguments.permitted(%w(functions))
         
     | 
| 
      
 45 
     | 
    
         
            +
                        )
         
     | 
| 
      
 46 
     | 
    
         
            +
                      end
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
                      def self.list
         
     | 
| 
      
 49 
     | 
    
         
            +
                        Resources::Region.instances(path: %w(functions))
         
     | 
| 
      
 50 
     | 
    
         
            +
                      end
         
     | 
| 
      
 51 
     | 
    
         
            +
                    end
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
                    module Remote
         
     | 
| 
      
 54 
     | 
    
         
            +
                      def self.list
         
     | 
| 
      
 55 
     | 
    
         
            +
                        Resources::Remote.instances(
         
     | 
| 
      
 56 
     | 
    
         
            +
                          path: %w(beta functions)
         
     | 
| 
      
 57 
     | 
    
         
            +
                        )
         
     | 
| 
      
 58 
     | 
    
         
            +
                      end
         
     | 
| 
      
 59 
     | 
    
         
            +
                    end
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
                    module Function
         
     | 
| 
      
 62 
     | 
    
         
            +
                      include GClouder::GCloud
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
                      def self.ensure(region, function)
         
     | 
| 
      
 65 
     | 
    
         
            +
                        filter_value = "projects/#{project['project_id']}/locations/#{region}/functions/#{function["name"]}"
         
     | 
| 
      
 66 
     | 
    
         
            +
                        type = Resource::resource?("beta functions", function["name"], filter_value: filter_value) ? "change" : "add"
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
                        Resource::feedback(type, "beta functions", function["name"])
         
     | 
| 
      
 69 
     | 
    
         
            +
                        gcloud "beta functions deploy #{function["name"]} #{hash_to_args(function)} --region=#{region}"
         
     | 
| 
      
 70 
     | 
    
         
            +
                      end
         
     | 
| 
      
 71 
     | 
    
         
            +
             
     | 
| 
      
 72 
     | 
    
         
            +
                      def self.purge(region, function)
         
     | 
| 
      
 73 
     | 
    
         
            +
                        Resource.purge :"beta functions", function["name"], "--region=#{region}"
         
     | 
| 
      
 74 
     | 
    
         
            +
                      end
         
     | 
| 
      
 75 
     | 
    
         
            +
                    end
         
     | 
| 
      
 76 
     | 
    
         
            +
                  end
         
     | 
| 
      
 77 
     | 
    
         
            +
                end
         
     | 
| 
      
 78 
     | 
    
         
            +
              end
         
     | 
| 
      
 79 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -7,6 +7,7 @@ module GClouder 
     | 
|
| 
       7 
7 
     | 
    
         
             
                    include GClouder::Logging
         
     | 
| 
       8 
8 
     | 
    
         
             
                    include GClouder::Shell
         
     | 
| 
       9 
9 
     | 
    
         
             
                    include GClouder::Resource::Cleaner
         
     | 
| 
      
 10 
     | 
    
         
            +
                    include GClouder::Config::Project
         
     | 
| 
       10 
11 
     | 
    
         | 
| 
       11 
12 
     | 
    
         
             
                    def self.header(stage = :ensure)
         
     | 
| 
       12 
13 
     | 
    
         
             
                      info "[#{stage}] storage / buckets", title: true, indent: 1
         
     | 
| 
         @@ -78,8 +79,7 @@ module GClouder 
     | 
|
| 
       78 
79 
     | 
    
         | 
| 
       79 
80 
     | 
    
         
             
                        return if cli_args[:dry_run]
         
     | 
| 
       80 
81 
     | 
    
         | 
| 
       81 
     | 
    
         
            -
                         
     | 
| 
       82 
     | 
    
         
            -
                        shell("gsutil defacl ch -u #{default_access} gs://#{bucket_name}")
         
     | 
| 
      
 82 
     | 
    
         
            +
                        gsutil "defacl ch", "-u #{default_access} gs://#{bucket_name}"
         
     | 
| 
       83 
83 
     | 
    
         
             
                      end
         
     | 
| 
       84 
84 
     | 
    
         | 
| 
       85 
85 
     | 
    
         
             
                      def self.check_exists?(region, bucket_name)
         
     | 
| 
         @@ -93,8 +93,7 @@ module GClouder 
     | 
|
| 
       93 
93 
     | 
    
         
             
                        end
         
     | 
| 
       94 
94 
     | 
    
         | 
| 
       95 
95 
     | 
    
         
             
                        add "#{bucket["name"]} [#{bucket["default_access"]}]"
         
     | 
| 
       96 
     | 
    
         
            -
                        gsutil "mb", "-l #{region} gs://#{bucket["name"]}"
         
     | 
| 
       97 
     | 
    
         
            -
             
     | 
| 
      
 96 
     | 
    
         
            +
                        gsutil "mb", "-p #{project['project_id']} -l #{region} gs://#{bucket["name"]}"
         
     | 
| 
       98 
97 
     | 
    
         | 
| 
       99 
98 
     | 
    
         
             
                        setDefaultAccess bucket["name"], bucket["default_access"] if bucket.key?("default_access")
         
     | 
| 
       100 
99 
     | 
    
         
             
                      end
         
     | 
| 
         @@ -41,7 +41,8 @@ module GClouder 
     | 
|
| 
       41 
41 
     | 
    
         
             
                        permitted_and_required_keys = {
         
     | 
| 
       42 
42 
     | 
    
         
             
                          "bucket"=>{"type"=>"String", "required"=>true},
         
     | 
| 
       43 
43 
     | 
    
         
             
                          "topic"=>{"type"=>"String", "required"=>true},
         
     | 
| 
       44 
     | 
    
         
            -
                          "events"=>{"type"=>"Array", "required"=>false}
         
     | 
| 
      
 44 
     | 
    
         
            +
                          "events"=>{"type"=>"Array", "required"=>false},
         
     | 
| 
      
 45 
     | 
    
         
            +
                          "prefix"=>{"type"=>"String", "required"=>false}
         
     | 
| 
       45 
46 
     | 
    
         
             
                        }
         
     | 
| 
       46 
47 
     | 
    
         | 
| 
       47 
48 
     | 
    
         
             
                        Resources::Validate::Region.instances(
         
     | 
| 
         @@ -80,8 +81,12 @@ module GClouder 
     | 
|
| 
       80 
81 
     | 
    
         
             
                        if notification.has_key?("events")
         
     | 
| 
       81 
82 
     | 
    
         
             
                          event_type_args = "-e #{notification["events"].join(",")}"
         
     | 
| 
       82 
83 
     | 
    
         
             
                        end
         
     | 
| 
      
 84 
     | 
    
         
            +
                        prefix_arg = ""
         
     | 
| 
      
 85 
     | 
    
         
            +
                        if notification.has_key?("prefix")
         
     | 
| 
      
 86 
     | 
    
         
            +
                          prefix_arg = "-p #{notification["prefix"]}"
         
     | 
| 
      
 87 
     | 
    
         
            +
                        end
         
     | 
| 
       83 
88 
     | 
    
         | 
| 
       84 
     | 
    
         
            -
                        args = "-t #{notification["name"]} #{event_type_args} -f json gs://#{notification["bucket"]}"
         
     | 
| 
      
 89 
     | 
    
         
            +
                        args = "-t #{notification["name"]} #{prefix_arg} #{event_type_args} -f json gs://#{notification["bucket"]}"
         
     | 
| 
       85 
90 
     | 
    
         | 
| 
       86 
91 
     | 
    
         
             
                        add "notification topic: #{notification["name"]}; bucket: #{notification["bucket"]}", indent: 4
         
     | 
| 
       87 
92 
     | 
    
         
             
                        gsutil "notification create", args
         
     | 
    
        data/lib/gclouder/version.rb
    CHANGED
    
    
    
        data/lib/gclouder.rb
    CHANGED
    
    | 
         @@ -80,6 +80,8 @@ require "gclouder/resources/pubsub/subscriptions" 
     | 
|
| 
       80 
80 
     | 
    
         | 
| 
       81 
81 
     | 
    
         
             
            require "gclouder/resources/logging/sinks"
         
     | 
| 
       82 
82 
     | 
    
         | 
| 
      
 83 
     | 
    
         
            +
            require "gclouder/resources/functions/function"
         
     | 
| 
      
 84 
     | 
    
         
            +
             
     | 
| 
       83 
85 
     | 
    
         
             
            module GClouder
         
     | 
| 
       84 
86 
     | 
    
         
             
              include GClouder::Logging
         
     | 
| 
       85 
87 
     | 
    
         
             
              include GClouder::Config::CLIArgs
         
     | 
| 
         @@ -253,6 +255,12 @@ module GClouder 
     | 
|
| 
       253 
255 
     | 
    
         
             
                    module: Resources::PubSub::Subscriptions,
         
     | 
| 
       254 
256 
     | 
    
         
             
                    skip: [ :check ],
         
     | 
| 
       255 
257 
     | 
    
         
             
                  },
         
     | 
| 
      
 258 
     | 
    
         
            +
             
     | 
| 
      
 259 
     | 
    
         
            +
                  {
         
     | 
| 
      
 260 
     | 
    
         
            +
                    name: "functions",
         
     | 
| 
      
 261 
     | 
    
         
            +
                    module: Resources::Functions::Function,
         
     | 
| 
      
 262 
     | 
    
         
            +
                    skip: [ :check, :clean ],
         
     | 
| 
      
 263 
     | 
    
         
            +
                  },
         
     | 
| 
       256 
264 
     | 
    
         
             
                ]
         
     | 
| 
       257 
265 
     | 
    
         
             
              end
         
     | 
| 
       258 
266 
     | 
    
         | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: gclouder
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.1. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.1.9
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Rob Wilson
         
     | 
| 
         @@ -9,7 +9,7 @@ authors: 
     | 
|
| 
       9 
9 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       10 
10 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       11 
11 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       12 
     | 
    
         
            -
            date: 2017-06- 
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2017-06-21 00:00:00.000000000 Z
         
     | 
| 
       13 
13 
     | 
    
         
             
            dependencies:
         
     | 
| 
       14 
14 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       15 
15 
     | 
    
         
             
              name: trollop
         
     | 
| 
         @@ -187,6 +187,7 @@ files: 
     | 
|
| 
       187 
187 
     | 
    
         
             
            - assets/arguments/container/node-pools.yml
         
     | 
| 
       188 
188 
     | 
    
         
             
            - assets/arguments/dns/managed-zones.yml
         
     | 
| 
       189 
189 
     | 
    
         
             
            - assets/arguments/dns/record-sets/transaction.yml
         
     | 
| 
      
 190 
     | 
    
         
            +
            - assets/arguments/functions.yml
         
     | 
| 
       190 
191 
     | 
    
         
             
            - assets/defaults/compute/disks.yml
         
     | 
| 
       191 
192 
     | 
    
         
             
            - assets/mappings/file.yml
         
     | 
| 
       192 
193 
     | 
    
         
             
            - assets/mappings/property.yml
         
     | 
| 
         @@ -245,6 +246,7 @@ files: 
     | 
|
| 
       245 
246 
     | 
    
         
             
            - lib/gclouder/resources/container/clusters.rb
         
     | 
| 
       246 
247 
     | 
    
         
             
            - lib/gclouder/resources/container/node_pools.rb
         
     | 
| 
       247 
248 
     | 
    
         
             
            - lib/gclouder/resources/dns.rb
         
     | 
| 
      
 249 
     | 
    
         
            +
            - lib/gclouder/resources/functions/function.rb
         
     | 
| 
       248 
250 
     | 
    
         
             
            - lib/gclouder/resources/logging/sinks.rb
         
     | 
| 
       249 
251 
     | 
    
         
             
            - lib/gclouder/resources/project.rb
         
     | 
| 
       250 
252 
     | 
    
         
             
            - lib/gclouder/resources/project/iam_policy_binding.rb
         
     |