generated from kyma-project/template-repository
/
fake.go
27 lines (22 loc) · 905 Bytes
/
fake.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
package node
import (
kmccache "github.com/kyma-project/kyma-metrics-collector/pkg/cache"
skrcommons "github.com/kyma-project/kyma-metrics-collector/pkg/skr/commons"
kmctesting "github.com/kyma-project/kyma-metrics-collector/pkg/testing"
"k8s.io/apimachinery/pkg/runtime/schema"
dynamicfake "k8s.io/client-go/dynamic/fake"
)
type FakeNodeClient struct{}
func (fakeNodeClient FakeNodeClient) NewClient(kmccache.Record) (*Client, error) {
nodeList := kmctesting.Get3NodesWithStandardD8v3VMType()
scheme, err := skrcommons.SetupScheme()
if err != nil {
return nil, err
}
dynamicClient := dynamicfake.NewSimpleDynamicClientWithCustomListKinds(scheme,
map[schema.GroupVersionResource]string{
{Group: "core", Version: "v1", Resource: "Node"}: "NodeList",
}, nodeList)
nsResourceClient := dynamicClient.Resource(GroupVersionResource())
return &Client{Resource: nsResourceClient}, nil
}