Skip to content

Commit

Permalink
Manually fill ActiveVersion value in GetService (#312)
Browse files Browse the repository at this point in the history
* Manually fill `ActiveVersion` value in `GetService`

* add break
  • Loading branch information
smaeda-ks authored Oct 11, 2021
1 parent a9496aa commit cdf54fc
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions fastly/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,18 @@ func (c *Client) GetService(i *GetServiceInput) (*Service, error) {
return nil, err
}

// NOTE: GET /service/:service_id endpoint does not return the "version" field
// unlike other GET service endpoints (/service, /service/:service_id/details).
// Therefore, ActiveVersion is always zero value when GetService is called.
// We work around this by manually finding the active version number from the
// "versions" array in the returned JSON response.
for i := range s.Versions {
if s.Versions[i].Active {
s.ActiveVersion = uint(s.Versions[i].Number)
break
}
}

return s, nil
}

Expand Down

0 comments on commit cdf54fc

Please sign in to comment.