...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package client
17
18 import (
19 "context"
20
21 "github.com/hasura/go-graphql-client"
22 "github.com/pkg/errors"
23 )
24
25 func (c *CtrlClient) CleanTcs(ctx context.Context, namespace, name string, devices []string) ([]string, error) {
26 var graphqlDevices []graphql.String
27 for _, dev := range devices {
28 graphqlDevices = append(graphqlDevices, graphql.String(dev))
29 }
30 var mutation struct {
31 Pod struct {
32 CleanTcs []string `graphql:"cleanTcs(devices: $devices)"`
33 } `graphql:"pod(ns: $ns, name: $name)"`
34 }
35
36 err := c.QueryClient.Mutate(ctx, &mutation, map[string]interface{}{
37 "devices": graphqlDevices,
38 "ns": graphql.String(namespace),
39 "name": graphql.String(name),
40 })
41
42 if err != nil {
43 return nil, errors.Wrapf(err, "cleaned tc rules for device %v", devices)
44 }
45
46 return mutation.Pod.CleanTcs, nil
47 }
48