-
Notifications
You must be signed in to change notification settings - Fork 67
/
polling.go
58 lines (44 loc) 路 1.5 KB
/
polling.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package actions
import (
"context"
"github.com/kubeshop/tracetest/cli/file"
"github.com/kubeshop/tracetest/cli/openapi"
"github.com/kubeshop/tracetest/cli/utils"
"github.com/kubeshop/tracetest/server/model/yaml"
)
type pollingActions struct {
resourceArgs
}
var _ ResourceActions = &pollingActions{}
func NewPollingActions(options ...ResourceArgsOption) pollingActions {
args := NewResourceArgs(options...)
return pollingActions{
resourceArgs: args,
}
}
func (pollingActions) FileType() yaml.FileType {
return yaml.FileTypePollingProfile
}
func (pollingActions) Name() string {
return "pollingprofile"
}
func (polling pollingActions) GetID(file *file.File) (string, error) {
resource, err := polling.formatter.ToStruct(file)
if err != nil {
return "", err
}
return resource.(openapi.PollingProfile).Spec.Id, nil
}
func (polling pollingActions) Apply(ctx context.Context, fileContent file.File) (result *file.File, err error) {
result, err = polling.resourceClient.Update(ctx, fileContent, currentConfigID)
return result, err
}
func (polling pollingActions) List(ctx context.Context, listArgs utils.ListArgs) (*file.File, error) {
return polling.resourceClient.List(ctx, listArgs)
}
func (polling pollingActions) Delete(ctx context.Context, ID string) (string, error) {
return "PollingProfile successfully reset to default", ErrNotSupportedResourceAction
}
func (polling pollingActions) Get(ctx context.Context, ID string) (*file.File, error) {
return polling.resourceClient.Get(ctx, currentConfigID)
}