This repository has been archived by the owner on Oct 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 63
/
resource.go
88 lines (74 loc) · 3.17 KB
/
resource.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package mocks
import (
"context"
"github.com/flyteorg/flyteadmin/pkg/manager/interfaces"
"github.com/flyteorg/flyteidl/gen/pb-go/flyteidl/admin"
)
type UpdateProjectDomainFunc func(ctx context.Context, request admin.ProjectDomainAttributesUpdateRequest) (
*admin.ProjectDomainAttributesUpdateResponse, error)
type GetProjectDomainFunc func(ctx context.Context, request admin.ProjectDomainAttributesGetRequest) (
*admin.ProjectDomainAttributesGetResponse, error)
type DeleteProjectDomainFunc func(ctx context.Context, request admin.ProjectDomainAttributesDeleteRequest) (
*admin.ProjectDomainAttributesDeleteResponse, error)
type ListResourceFunc func(ctx context.Context, request admin.ListMatchableAttributesRequest) (
*admin.ListMatchableAttributesResponse, error)
type GetResourceFunc func(ctx context.Context, request interfaces.ResourceRequest) (*interfaces.ResourceResponse, error)
type MockResourceManager struct {
updateProjectDomainFunc UpdateProjectDomainFunc
GetFunc GetProjectDomainFunc
DeleteFunc DeleteProjectDomainFunc
ListFunc ListResourceFunc
GetResourceFunc GetResourceFunc
}
func (m *MockResourceManager) GetResource(ctx context.Context, request interfaces.ResourceRequest) (*interfaces.ResourceResponse, error) {
if m.GetResourceFunc != nil {
return m.GetResourceFunc(ctx, request)
}
return nil, nil
}
func (m *MockResourceManager) UpdateWorkflowAttributes(ctx context.Context, request admin.WorkflowAttributesUpdateRequest) (
*admin.WorkflowAttributesUpdateResponse, error) {
panic("implement me")
}
func (m *MockResourceManager) GetWorkflowAttributes(ctx context.Context, request admin.WorkflowAttributesGetRequest) (
*admin.WorkflowAttributesGetResponse, error) {
panic("implement me")
}
func (m *MockResourceManager) DeleteWorkflowAttributes(ctx context.Context, request admin.WorkflowAttributesDeleteRequest) (
*admin.WorkflowAttributesDeleteResponse, error) {
panic("implement me")
}
func (m *MockResourceManager) SetUpdateProjectDomainAttributes(updateProjectDomainFunc UpdateProjectDomainFunc) {
m.updateProjectDomainFunc = updateProjectDomainFunc
}
func (m *MockResourceManager) UpdateProjectDomainAttributes(
ctx context.Context, request admin.ProjectDomainAttributesUpdateRequest) (
*admin.ProjectDomainAttributesUpdateResponse, error) {
if m.updateProjectDomainFunc != nil {
return m.updateProjectDomainFunc(ctx, request)
}
return nil, nil
}
func (m *MockResourceManager) GetProjectDomainAttributes(
ctx context.Context, request admin.ProjectDomainAttributesGetRequest) (
*admin.ProjectDomainAttributesGetResponse, error) {
if m.GetFunc != nil {
return m.GetFunc(ctx, request)
}
return nil, nil
}
func (m *MockResourceManager) DeleteProjectDomainAttributes(
ctx context.Context, request admin.ProjectDomainAttributesDeleteRequest) (
*admin.ProjectDomainAttributesDeleteResponse, error) {
if m.DeleteFunc != nil {
return m.DeleteFunc(ctx, request)
}
return nil, nil
}
func (m *MockResourceManager) ListAll(ctx context.Context, request admin.ListMatchableAttributesRequest) (
*admin.ListMatchableAttributesResponse, error) {
if m.ListFunc != nil {
return m.ListFunc(ctx, request)
}
return nil, nil
}