Jon Perritt | efe6d1f | 2015-02-09 12:04:06 -0700 | [diff] [blame] | 1 | package buildinfo |
| 2 | |
| 3 | import ( |
| 4 | "github.com/mitchellh/mapstructure" |
| 5 | "github.com/rackspace/gophercloud" |
| 6 | ) |
| 7 | |
Jon Perritt | 99f6312 | 2015-02-11 12:39:55 -0700 | [diff] [blame] | 8 | // Revision represents the API/Engine revision of a Heat deployment. |
Jon Perritt | efe6d1f | 2015-02-09 12:04:06 -0700 | [diff] [blame] | 9 | type Revision struct { |
| 10 | Revision string `mapstructure:"revision"` |
| 11 | } |
| 12 | |
| 13 | // BuildInfo represents the build information for a Heat deployment. |
| 14 | type BuildInfo struct { |
| 15 | API Revision `mapstructure:"api"` |
| 16 | Engine Revision `mapstructure:"engine"` |
| 17 | } |
| 18 | |
| 19 | // GetResult represents the result of a Get operation. |
| 20 | type GetResult struct { |
| 21 | gophercloud.Result |
| 22 | } |
| 23 | |
| 24 | // Extract returns a pointer to a BuildInfo object and is called after a |
| 25 | // Get operation. |
| 26 | func (r GetResult) Extract() (*BuildInfo, error) { |
| 27 | if r.Err != nil { |
| 28 | return nil, r.Err |
| 29 | } |
| 30 | |
| 31 | var res BuildInfo |
| 32 | if err := mapstructure.Decode(r.Body, &res); err != nil { |
| 33 | return nil, err |
| 34 | } |
| 35 | |
| 36 | return &res, nil |
| 37 | } |