-
Notifications
You must be signed in to change notification settings - Fork 0
/
log.resolvers.go
36 lines (29 loc) · 1.11 KB
/
log.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
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"
)
// Log is the resolver for the log field.
func (r *subscriptionResolver) Log(ctx context.Context, input *model.LogSubscriptionInput) (<-chan *model.LogLine, error) {
container := ""
selector := ""
switch {
case input.App != nil:
selector = "app=" + *input.App
container = *input.App
case input.Job != nil:
selector = "app=" + *input.Job
container = *input.Job
default:
return nil, fmt.Errorf("must specify either app or job")
}
return r.k8sClient.LogStream(ctx, input.Env, input.Team.String(), selector, container, input.Instances)
}
// Subscription returns gengql.SubscriptionResolver implementation.
func (r *Resolver) Subscription() gengql.SubscriptionResolver { return &subscriptionResolver{r} }
type subscriptionResolver struct{ *Resolver }