Skip to content

Commit

Permalink
feat: generated client implements kv interface
Browse files Browse the repository at this point in the history
In order to allow using fakeclient in unit tests,
the kv generated client has to implement all the custom methods
not autogenerated:
- PatchStatus

Signed-off-by: fossedihelm <ffossemo@redhat.com>
  • Loading branch information
fossedihelm committed Apr 17, 2024
1 parent 8d0583d commit db4b3bf
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 4 deletions.
Expand Up @@ -8,6 +8,7 @@ go_library(
"doc.go",
"generated_expansion.go",
"kubevirt.go",
"kubevirt_expansion.go",
"streamer.go",
"virtualmachine.go",
"virtualmachine_expansion.go",
Expand Down
Expand Up @@ -6,6 +6,7 @@ go_library(
"doc.go",
"fake_core_client.go",
"fake_kubevirt.go",
"fake_kubevirt_expansion.go",
"fake_virtualmachine.go",
"fake_virtualmachine_expansion.go",
"fake_virtualmachineinstance.go",
Expand Down
@@ -0,0 +1,33 @@
/*
* This file is part of the KubeVirt project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Copyright The KubeVirt Authors
*
*/

package fake

import (
"context"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"

v1 "kubevirt.io/api/core/v1"
)

func (c *FakeKubeVirts) PatchStatus(ctx context.Context, name string, pt types.PatchType, data []byte, patchOptions metav1.PatchOptions) (*v1.KubeVirt, error) {
return c.Patch(ctx, name, pt, data, patchOptions, "status")
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

@@ -0,0 +1,38 @@
/*
* This file is part of the KubeVirt project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Copyright The KubeVirt Authors
*
*/

package v1

import (
"context"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"

v1 "kubevirt.io/api/core/v1"
)

type KubeVirtExpansion interface {
PatchStatus(ctx context.Context, name string, pt types.PatchType, data []byte, patchOptions metav1.PatchOptions) (*v1.KubeVirt, error)
}

func (c *kubeVirts) PatchStatus(ctx context.Context, name string, pt types.PatchType, data []byte, patchOptions metav1.PatchOptions) (*v1.KubeVirt, error) {
// TODO not implemented yet
return nil, nil
}
2 changes: 0 additions & 2 deletions staging/src/kubevirt.io/client-go/kubecli/kubevirt.go
Expand Up @@ -26,7 +26,6 @@ package kubecli
*/

import (
"context"
"time"

routev1 "github.com/openshift/client-go/route/clientset/versioned/typed/route/v1"
Expand Down Expand Up @@ -269,7 +268,6 @@ type VirtualMachineInstanceMigrationInterface interface {

type KubeVirtInterface interface {
kvcorev1.KubeVirtInterface
PatchStatus(ctx context.Context, name string, pt types.PatchType, data []byte, patchOptions metav1.PatchOptions) (result *v1.KubeVirt, err error)
}

type ServerVersionInterface interface {
Expand Down

0 comments on commit db4b3bf

Please sign in to comment.