Skip to content

Commit

Permalink
Struct changes
Browse files Browse the repository at this point in the history
  • Loading branch information
GJSBRT committed Apr 18, 2023
1 parent 5b16efd commit aa11bdd
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions dutchis/virtualserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@ import (
)

type VirtualServer struct {
UUID string `json:"uuid"`
Name string `json:"name"`
Class string `json:"class"`
Status string `json:"status"`
Node string `json:"node"`
Success bool `json:"success"`
Data struct {
UUID string `json:"uuid"`
Name string `json:"name"`
Class string `json:"class"`
Status string `json:"status"`
Node string `json:"node"`
}
}

// using a global variable here so that we have an internally accessible
Expand Down Expand Up @@ -171,7 +174,13 @@ func resourceVirtualServerCreate(d *schema.ResourceData, meta interface{}) error
return err
}

var virtualserver VirtualServer
type NewVirtualServerResponse struct {
Success bool `json:"success"`
Message string `json:"message"`
UUID string `json:"uuid"`
}

var virtualserver NewVirtualServerResponse
if err := json.Unmarshal(body, &virtualserver); err != nil {
logger.Error().Err(err).Msg("Failed to unmarshal JSON")
return err
Expand Down Expand Up @@ -222,7 +231,7 @@ func resourceVirtualServerRead(d *schema.ResourceData, meta interface{}) error {
return err
}

d.Set("hostname", virtualserver.Name)
d.Set("hostname", virtualserver.Data.Name)

logger.Info().Msg("Read configuration for virtual server: " + d.Id())

Expand Down

0 comments on commit aa11bdd

Please sign in to comment.