Skip to content

Commit

Permalink
Add Image property to server (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
thetechnick authored and thcyron committed Jan 22, 2018
1 parent 197f445 commit 80f3404
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
3 changes: 3 additions & 0 deletions hcloud/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ func ServerFromSchema(s schema.Server) *Server {
Datacenter: DatacenterFromSchema(s.Datacenter),
Locked: s.Locked,
}
if s.Image != nil {
server.Image = ImageFromSchema(*s.Image)
}
if s.BackupWindow != nil {
server.BackupWindow = *s.BackupWindow
}
Expand Down
1 change: 1 addition & 0 deletions hcloud/schema/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type Server struct {
ISO *ISO `json:"iso"`
Locked bool `json:"locked"`
Datacenter Datacenter `json:"datacenter"`
Image *Image `json:"image"`
}

// ServerPublicNet defines the schema of a server's
Expand Down
21 changes: 21 additions & 0 deletions hcloud/schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,24 @@ func TestServerFromSchema(t *testing.T) {
"included_traffic": 654321,
"backup_window": "22-02",
"rescue_enabled": true,
"image": {
"id": 4711,
"type": "system",
"status": "available",
"name": "ubuntu16.04-standard-x64",
"description": "Ubuntu 16.04 Standard 64 bit",
"image_size": 2.3,
"disk_size": 10,
"created": "2017-08-16T17:29:14+00:00",
"created_from": {
"id": 1,
"name": "Server"
},
"bound_to": 1,
"os_flavor": "ubuntu",
"os_version": "16.04",
"rapid_deploy": false
},
"iso": {
"id": 4711,
"name": "FreeBSD-11.0-RELEASE-amd64-dvd1",
Expand Down Expand Up @@ -352,6 +370,9 @@ func TestServerFromSchema(t *testing.T) {
if !server.RescueEnabled {
t.Errorf("unexpected rescue enabled state: %v", server.RescueEnabled)
}
if server.Image == nil || server.Image.ID != 4711 {
t.Errorf("unexpected Image: %v", server.Image)
}
if server.ISO == nil || server.ISO.ID != 4711 {
t.Errorf("unexpected ISO: %v", server.ISO)
}
Expand Down
1 change: 1 addition & 0 deletions hcloud/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type Server struct {
RescueEnabled bool
Locked bool
ISO *ISO
Image *Image
}

// ServerStatus specifies a server's status.
Expand Down

0 comments on commit 80f3404

Please sign in to comment.