Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: yaroslavborbat <[email protected]>
  • Loading branch information
yaroslavborbat committed Jan 20, 2025
1 parent 58445ad commit 7dad1be
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 23 deletions.
5 changes: 2 additions & 3 deletions api/client/kubeclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ import (
)

var (
Scheme = runtime.NewScheme()
Codecs = serializer.NewCodecFactory(Scheme)
ParameterCodec = runtime.NewParameterCodec(Scheme)
Scheme = runtime.NewScheme()
Codecs = serializer.NewCodecFactory(Scheme)
)

func init() {
Expand Down
26 changes: 11 additions & 15 deletions api/client/kubeclient/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
"time"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/rest"
virtv1 "kubevirt.io/api/core/v1"

Expand Down Expand Up @@ -153,27 +152,24 @@ func (v vm) Migrate(ctx context.Context, name string, opts v1alpha2.VirtualMachi

func (v vm) AddVolume(ctx context.Context, name string, opts v1alpha2.VirtualMachineAddVolume) error {
path := fmt.Sprintf(subresourceURLTpl, v.namespace, v.resource, name, "addvolume")
opts.TypeMeta = metav1.TypeMeta{
Kind: v1alpha2.VirtualMachineAddVolumeKind,
APIVersion: v1alpha2.SchemeGroupVersion.String(),
}
return v.doRequest(ctx, path, &opts)
return v.restClient.
Put().
AbsPath(path).
Param("name", opts.Name).
Param("volumeKind", opts.VolumeKind).
Param("pvcName", opts.PVCName).
Param("image", opts.Image).
Param("isCdrom", strconv.FormatBool(opts.IsCdrom)).
Do(ctx).
Error()
}

func (v vm) RemoveVolume(ctx context.Context, name string, opts v1alpha2.VirtualMachineRemoveVolume) error {
path := fmt.Sprintf(subresourceURLTpl, v.namespace, v.resource, name, "removevolume")
opts.TypeMeta = metav1.TypeMeta{
Kind: v1alpha2.VirtualMachineRemoveVolumeKind,
APIVersion: v1alpha2.SchemeGroupVersion.String(),
}
return v.doRequest(ctx, path, &opts)
}

func (v vm) doRequest(ctx context.Context, path string, obj runtime.Object) error {
return v.restClient.
Put().
AbsPath(path).
VersionedParams(obj, ParameterCodec).
Param("name", opts.Name).
Do(ctx).
Error()
}
5 changes: 0 additions & 5 deletions api/subresources/v1alpha2/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ package v1alpha2

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

const (
VirtualMachineAddVolumeKind = "VirtualMachineAddVolume"
VirtualMachineRemoveVolumeKind = "VirtualMachineRemoveVolume"
)

// +genclient
// +genclient:readonly
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
Expand Down

0 comments on commit 7dad1be

Please sign in to comment.