kumogata 0.1.3 → 0.1.4
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 +8 -8
- data/README.md +34 -2
- data/lib/kumogata/client.rb +41 -4
- data/lib/kumogata/version.rb +1 -1
- metadata +1 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,15 +1,15 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            !binary "U0hBMQ==":
         | 
| 3 3 | 
             
              metadata.gz: !binary |-
         | 
| 4 | 
            -
                 | 
| 4 | 
            +
                MmU2ZWQyYmY3MzE5MzRjOTg2OTczZjllYWRlYTAyZTg3YmZlM2NkZA==
         | 
| 5 5 | 
             
              data.tar.gz: !binary |-
         | 
| 6 | 
            -
                 | 
| 6 | 
            +
                NjFlZWIzYWYxMjBjODE1YmE3M2ZiYjYxYzdhNjNlYmZkMTRjNTk4OQ==
         | 
| 7 7 | 
             
            SHA512:
         | 
| 8 8 | 
             
              metadata.gz: !binary |-
         | 
| 9 | 
            -
                 | 
| 10 | 
            -
                 | 
| 11 | 
            -
                 | 
| 9 | 
            +
                ZjNmZjViNTc4ZjlmNDlhY2ViYjFjMDNmMmRkY2Q0MGRmNDYyMDkxNjE5ZTlk
         | 
| 10 | 
            +
                NDU2MTQ0MzNkMWI5ZDMzNWE5NzIzYmZjNzc1ODQ2YjExMGFhN2Y4M2YzZjc4
         | 
| 11 | 
            +
                OTIwYWU2YTc5Njc3MWM3Njc3NTY0YzVmNTllYTI4NzMzMDNjZmE=
         | 
| 12 12 | 
             
              data.tar.gz: !binary |-
         | 
| 13 | 
            -
                 | 
| 14 | 
            -
                 | 
| 15 | 
            -
                 | 
| 13 | 
            +
                ZjRjODY4MWI2MTliN2JlNjhiMzc2OWIzYmE4MzE1NGM4ZGU4YTUyMDlmNTI2
         | 
| 14 | 
            +
                YTY3NWNiZGY1YWNhOTE3Y2VkMjA5NmY1MmNmYzY1YmY5NjFkNzgyYjJhNTI1
         | 
| 15 | 
            +
                ZGM5ZTU0MDZmZTc5OWU4OGI5ZGEzNGIzNzY4ZmZjZTc3ZTY4ODE=
         | 
    
        data/README.md
    CHANGED
    
    | @@ -2,8 +2,8 @@ | |
| 2 2 |  | 
| 3 3 | 
             
            Kumogata is a tool for [AWS CloudFormation](https://aws.amazon.com/cloudformation/).
         | 
| 4 4 |  | 
| 5 | 
            -
            [](http://badge.fury.io/rb/kumogata)
         | 
| 6 | 
            +
            [](https://drone.io/github.com/winebarrel/kumogata/latest)
         | 
| 7 7 |  | 
| 8 8 | 
             
            It can define a template in Ruby DSL, such as:
         | 
| 9 9 |  | 
| @@ -116,6 +116,38 @@ JSON template can be converted to Ruby template. | |
| 116 116 | 
             
            * `_path()` creates Hash that has a key of path
         | 
| 117 117 | 
             
              * `_path("/etc/passwd-s3fs") { content "..." }` => `{"/etc/passwd-s3fs": {"content": "..."}}`
         | 
| 118 118 |  | 
| 119 | 
            +
            ### _joine()
         | 
| 120 | 
            +
             | 
| 121 | 
            +
            Ruby templates will be converted as follows by `_join()`:
         | 
| 122 | 
            +
             | 
| 123 | 
            +
            ```ruby
         | 
| 124 | 
            +
            UserData do
         | 
| 125 | 
            +
              Fn__Base64 _join(<<-EOS)
         | 
| 126 | 
            +
                #!/bin/bash,
         | 
| 127 | 
            +
                /opt/aws/bin/cfn-init -s <%= Ref "AWS::StackId" %> -r myEC2Instance --region <%= Ref "AWS::Region" %>
         | 
| 128 | 
            +
              EOS
         | 
| 129 | 
            +
            end
         | 
| 130 | 
            +
            ```
         | 
| 131 | 
            +
             | 
| 132 | 
            +
            ```javascript
         | 
| 133 | 
            +
            "Fn::Base64": {
         | 
| 134 | 
            +
              "Fn::Join": [
         | 
| 135 | 
            +
                "",
         | 
| 136 | 
            +
                [
         | 
| 137 | 
            +
                  "#!/bin/bash,\n          /opt/aws/bin/cfn-init -s\n",
         | 
| 138 | 
            +
                  {
         | 
| 139 | 
            +
                    "Ref": "AWS::StackId"
         | 
| 140 | 
            +
                  },
         | 
| 141 | 
            +
                  "-r myEC2Instance --region\n",
         | 
| 142 | 
            +
                  {
         | 
| 143 | 
            +
                    "Ref": "AWS::Region"
         | 
| 144 | 
            +
                  },
         | 
| 145 | 
            +
                  "\n"
         | 
| 146 | 
            +
                ]
         | 
| 147 | 
            +
              ]
         | 
| 148 | 
            +
            }
         | 
| 149 | 
            +
            ```
         | 
| 150 | 
            +
             | 
| 119 151 | 
             
            ## Demo
         | 
| 120 152 |  | 
| 121 153 | 
             
            * Create resources
         | 
    
        data/lib/kumogata/client.rb
    CHANGED
    
    | @@ -146,9 +146,46 @@ class Kumogata::Client | |
| 146 146 | 
             
              end
         | 
| 147 147 |  | 
| 148 148 | 
             
              def define_template_func(scope)
         | 
| 149 | 
            -
                scope.instance_eval | 
| 150 | 
            -
                  def _user_data(data)
         | 
| 151 | 
            -
                     | 
| 149 | 
            +
                scope.instance_eval(<<-'EOS')
         | 
| 150 | 
            +
                  def _user_data(data, options = {})
         | 
| 151 | 
            +
                    options = {
         | 
| 152 | 
            +
                      :encode => true,
         | 
| 153 | 
            +
                      :strip  => true,
         | 
| 154 | 
            +
                    }.merge(options)
         | 
| 155 | 
            +
             | 
| 156 | 
            +
                    data = data.strip_lines + "\n" if options[:strip]
         | 
| 157 | 
            +
                    data = data.encode64 if options[:encode]
         | 
| 158 | 
            +
                    return data
         | 
| 159 | 
            +
                  end
         | 
| 160 | 
            +
             | 
| 161 | 
            +
                  def _join(data, options = {})
         | 
| 162 | 
            +
                    options = {
         | 
| 163 | 
            +
                      :strip  => true,
         | 
| 164 | 
            +
                      :trim_mode => nil,
         | 
| 165 | 
            +
                    }.merge(options)
         | 
| 166 | 
            +
             | 
| 167 | 
            +
             | 
| 168 | 
            +
                    @__refs__ = []
         | 
| 169 | 
            +
                    def Ref(value); @__refs__ << {"Ref" => value}; "\0"; end
         | 
| 170 | 
            +
                    data = ERB.new(data, nil, options[:trim_mode]).result(binding)
         | 
| 171 | 
            +
                    undef Ref
         | 
| 172 | 
            +
             | 
| 173 | 
            +
                    data = data.split("\0").zip(@__refs__)
         | 
| 174 | 
            +
                    @__refs__ = nil
         | 
| 175 | 
            +
             | 
| 176 | 
            +
                    data = data.flatten.select {|i| not i.nil? }
         | 
| 177 | 
            +
             | 
| 178 | 
            +
                    unless data.last.kind_of?(String) and data.last =~ /\n\Z/
         | 
| 179 | 
            +
                      data << "\n"
         | 
| 180 | 
            +
                    end
         | 
| 181 | 
            +
             | 
| 182 | 
            +
                    if options[:strip]
         | 
| 183 | 
            +
                      data = data.map {|i| i.kind_of?(String) ? i.strip + "\n" : i }
         | 
| 184 | 
            +
                    end
         | 
| 185 | 
            +
             | 
| 186 | 
            +
                    return {
         | 
| 187 | 
            +
                      "Fn::Join" => ["", data]
         | 
| 188 | 
            +
                    }
         | 
| 152 189 | 
             
                  end
         | 
| 153 190 |  | 
| 154 191 | 
             
                  def _path(path, value = nil, &block)
         | 
| @@ -158,7 +195,7 @@ class Kumogata::Client | |
| 158 195 |  | 
| 159 196 | 
             
                    @__hash__[path] = value
         | 
| 160 197 | 
             
                  end
         | 
| 161 | 
            -
                 | 
| 198 | 
            +
                EOS
         | 
| 162 199 | 
             
              end
         | 
| 163 200 |  | 
| 164 201 | 
             
              def create_stack(template, stack_name)
         | 
    
        data/lib/kumogata/version.rb
    CHANGED