...

Source file src/kubevirt.io/client-go/api/utils.go

Documentation: kubevirt.io/client-go/api

     1  /*
     2   * This file is part of the KubeVirt project
     3   *
     4   * Licensed under the Apache License, Version 2.0 (the "License");
     5   * you may not use this file except in compliance with the License.
     6   * You may obtain a copy of the License at
     7   *
     8   *     http://www.apache.org/licenses/LICENSE-2.0
     9   *
    10   * Unless required by applicable law or agreed to in writing, software
    11   * distributed under the License is distributed on an "AS IS" BASIS,
    12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13   * See the License for the specific language governing permissions and
    14   * limitations under the License.
    15   *
    16   * Copyright 2017 Red Hat, Inc.
    17   *
    18   */
    19  
    20  package api
    21  
    22  import (
    23  	k8sv1 "k8s.io/api/core/v1"
    24  	"k8s.io/apimachinery/pkg/api/resource"
    25  	k8smetav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    26  
    27  	v1 "kubevirt.io/api/core/v1"
    28  )
    29  
    30  // This is meant for testing
    31  func NewMinimalVMI(name string) *v1.VirtualMachineInstance {
    32  	return NewMinimalVMIWithNS(k8sv1.NamespaceDefault, name)
    33  }
    34  
    35  // This is meant for testing
    36  func NewMinimalVMIWithNS(namespace, name string) *v1.VirtualMachineInstance {
    37  	vmi := v1.NewVMIReferenceFromNameWithNS(namespace, name)
    38  	vmi.Spec = v1.VirtualMachineInstanceSpec{Domain: v1.DomainSpec{}}
    39  	vmi.Spec.Domain.Resources.Requests = k8sv1.ResourceList{
    40  		k8sv1.ResourceMemory: resource.MustParse("8192Ki"),
    41  	}
    42  	vmi.TypeMeta = k8smetav1.TypeMeta{
    43  		APIVersion: v1.GroupVersion.String(),
    44  		Kind:       "VirtualMachineInstance",
    45  	}
    46  	return vmi
    47  }
    48  

View as plain text