-
Notifications
You must be signed in to change notification settings - Fork 0
/
deployinfo.resolvers.go
44 lines (34 loc) · 1.37 KB
/
deployinfo.resolvers.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package graph
// This file will be automatically regenerated based on the schema, any resolver implementations
// will be copied through when generating and any unknown code will be moved to the end.
// Code generated by github.com/99designs/gqlgen
import (
"context"
"fmt"
"github.com/nais/api/internal/graph/gengql"
"github.com/nais/api/internal/graph/model"
"github.com/nais/api/internal/thirdparty/hookd"
)
// History is the resolver for the history field.
func (r *deployInfoResolver) History(ctx context.Context, obj *model.DeployInfo, offset *int, limit *int) (model.DeploymentResponse, error) {
name := obj.GQLVars.App
kind := "Application"
if obj.GQLVars.Job != "" {
kind = "Naisjob"
name = obj.GQLVars.Job
}
deploys, err := r.hookdClient.Deployments(ctx, hookd.WithTeam(obj.GQLVars.Team.String()), hookd.WithCluster(obj.GQLVars.Env))
if err != nil {
return nil, fmt.Errorf("getting deploys from Hookd: %w", err)
}
deploys = filterDeploysByNameAndKind(deploys, name, kind)
pagination := model.NewPagination(offset, limit)
n, pi := model.PaginatedSlice(deploys, pagination)
return &model.DeploymentList{
Nodes: deployToModel(n),
PageInfo: pi,
}, nil
}
// DeployInfo returns gengql.DeployInfoResolver implementation.
func (r *Resolver) DeployInfo() gengql.DeployInfoResolver { return &deployInfoResolver{r} }
type deployInfoResolver struct{ *Resolver }