Skip to content

Commit edd0fb3

Browse files
authored
Add ability to get last deploy of a service (#545)
* Add ability to get last deploy of a service * fix linting
1 parent 9e01362 commit edd0fb3

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
kind: Feature
2+
body: Add utility function to service struct to `GetLastDeploy` event
3+
time: 2025-05-14T15:06:22.701659-05:00

service.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ type Service struct {
4040
Dependencies *ServiceDependenciesConnection `graphql:"-"`
4141
Dependents *ServiceDependentsConnection `graphql:"-"`
4242

43+
LastDeploy *Deploy `graphql:"-"`
4344
Properties *ServicePropertiesConnection `graphql:"-"`
4445
}
4546

@@ -227,6 +228,27 @@ func (service *Service) GetTags(client *Client, variables *PayloadVariables) (*T
227228
return service.Tags, nil
228229
}
229230

231+
func (service *Service) GetLastDeploy(client *Client, variables *PayloadVariables) (*Deploy, error) {
232+
var q struct {
233+
Account struct {
234+
Service struct {
235+
LastDeploy Deploy
236+
} `graphql:"service(id: $service)"`
237+
}
238+
}
239+
if service.Id == "" {
240+
return nil, fmt.Errorf("unable to get LastDeploy, invalid service id: '%s'", service.Id)
241+
}
242+
if variables == nil {
243+
variables = client.InitialPageVariablesPointer()
244+
}
245+
(*variables)["service"] = service.Id
246+
if err := client.Query(&q, *variables, WithName("ServiceLastDeploy")); err != nil {
247+
return nil, err
248+
}
249+
return &q.Account.Service.LastDeploy, nil
250+
}
251+
230252
func (service *Service) GetAliases() []string {
231253
return service.Aliases
232254
}

0 commit comments

Comments
 (0)