mirror of
https://github.com/vmware-tanzu/velero.git
synced 2025-12-23 06:15:21 +00:00
chore: define common aliases for k8s packages (#8672)
Some checks failed
Run the E2E test on kind / build (push) Failing after 6m48s
Run the E2E test on kind / setup-test-matrix (push) Successful in 3s
Run the E2E test on kind / run-e2e-test (push) Has been skipped
Main CI / Build (push) Failing after 35s
Close stale issues and PRs / stale (push) Successful in 8s
Trivy Nightly Scan / Trivy nightly scan (velero, main) (push) Failing after 1m11s
Trivy Nightly Scan / Trivy nightly scan (velero-plugin-for-aws, main) (push) Failing after 47s
Trivy Nightly Scan / Trivy nightly scan (velero-plugin-for-gcp, main) (push) Failing after 49s
Trivy Nightly Scan / Trivy nightly scan (velero-plugin-for-microsoft-azure, main) (push) Failing after 43s
Some checks failed
Run the E2E test on kind / build (push) Failing after 6m48s
Run the E2E test on kind / setup-test-matrix (push) Successful in 3s
Run the E2E test on kind / run-e2e-test (push) Has been skipped
Main CI / Build (push) Failing after 35s
Close stale issues and PRs / stale (push) Successful in 8s
Trivy Nightly Scan / Trivy nightly scan (velero, main) (push) Failing after 1m11s
Trivy Nightly Scan / Trivy nightly scan (velero-plugin-for-aws, main) (push) Failing after 47s
Trivy Nightly Scan / Trivy nightly scan (velero-plugin-for-gcp, main) (push) Failing after 49s
Trivy Nightly Scan / Trivy nightly scan (velero-plugin-for-microsoft-azure, main) (push) Failing after 43s
* lchore: define common alias for k8s packages Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com> * Update .golangci.yaml Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com> * Update .golangci.yaml Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com> * Update .golangci.yaml Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com> --------- Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
This commit is contained in:
@@ -25,7 +25,7 @@ import (
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
"github.com/pkg/errors"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
corev1api "k8s.io/api/core/v1"
|
||||
|
||||
. "github.com/vmware-tanzu/velero/test"
|
||||
. "github.com/vmware-tanzu/velero/test/e2e/test"
|
||||
@@ -113,7 +113,7 @@ func (v *BackupVolumeInfo) CreateResources() error {
|
||||
pvcCount := 4
|
||||
Expect(pvcCount).To(BeNumerically(">", 3))
|
||||
|
||||
var vols []*v1.Volume
|
||||
var vols []*corev1api.Volume
|
||||
for i := 0; i <= pvcCount-1; i++ {
|
||||
pvcName := fmt.Sprintf("volume-info-pvc-%d", i)
|
||||
pvc, err := CreatePVC(v.Client, createNSName, pvcName, StorageClassName, nil)
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
corev1api "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/util/intstr"
|
||||
|
||||
velerov1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
|
||||
@@ -167,8 +167,8 @@ func (n *NodePort) Restore() error {
|
||||
|
||||
func createServiceWithNodeport(ctx context.Context, client TestClient, namespace string,
|
||||
service string, labels map[string]string, nodePort int32) error {
|
||||
serviceSpec := &v1.ServiceSpec{
|
||||
Ports: []v1.ServicePort{
|
||||
serviceSpec := &corev1api.ServiceSpec{
|
||||
Ports: []corev1api.ServicePort{
|
||||
{
|
||||
Port: 80,
|
||||
TargetPort: intstr.IntOrString{IntVal: 80},
|
||||
@@ -176,7 +176,7 @@ func createServiceWithNodeport(ctx context.Context, client TestClient, namespace
|
||||
},
|
||||
},
|
||||
Selector: nil,
|
||||
Type: v1.ServiceTypeLoadBalancer,
|
||||
Type: corev1api.ServiceTypeLoadBalancer,
|
||||
}
|
||||
return CreateService(ctx, client, namespace, service, labels, serviceSpec)
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
. "github.com/vmware-tanzu/velero/test/e2e/test"
|
||||
. "github.com/vmware-tanzu/velero/test/util/k8s"
|
||||
@@ -61,7 +61,7 @@ func (m *MultiNSBackup) Init() error {
|
||||
|
||||
// Currently it's hard to build a large list of namespaces to include and wildcards do not work so instead
|
||||
// we will exclude all of the namespaces that existed prior to the test from the backup
|
||||
namespaces, err := m.Client.ClientGo.CoreV1().Namespaces().List(context.Background(), v1.ListOptions{})
|
||||
namespaces, err := m.Client.ClientGo.CoreV1().Namespaces().List(context.Background(), metav1.ListOptions{})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "Could not retrieve namespaces")
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import (
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
"github.com/pkg/errors"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
corev1api "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/api/resource"
|
||||
|
||||
. "github.com/vmware-tanzu/velero/test"
|
||||
@@ -186,7 +186,7 @@ func (r *ResourcePoliciesCase) Clean() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *ResourcePoliciesCase) createPVC(index int, namespace string, volList []*v1.Volume) error {
|
||||
func (r *ResourcePoliciesCase) createPVC(index int, namespace string, volList []*corev1api.Volume) error {
|
||||
var err error
|
||||
for i := range volList {
|
||||
pvcName := fmt.Sprintf("pvc-%d", i)
|
||||
@@ -208,7 +208,7 @@ func (r *ResourcePoliciesCase) createPVC(index int, namespace string, volList []
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *ResourcePoliciesCase) createDeploymentWithVolume(namespace string, volList []*v1.Volume) error {
|
||||
func (r *ResourcePoliciesCase) createDeploymentWithVolume(namespace string, volList []*corev1api.Volume) error {
|
||||
deployment := NewDeployment(r.CaseBaseName, namespace, 1, map[string]string{"resource-policies": "resource-policies"}, nil).WithVolume(volList).Result()
|
||||
deployment, err := CreateDeployment(r.Client.ClientGo, namespace, deployment)
|
||||
if err != nil {
|
||||
|
||||
@@ -25,7 +25,7 @@ import (
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/net/context"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
corev1api "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
|
||||
@@ -64,12 +64,12 @@ func WaitForPods(ctx context.Context, client TestClient, namespace string, pods
|
||||
checkPod, err := client.ClientGo.CoreV1().Pods(namespace).Get(context.TODO(), podName, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
//Should ignore "etcdserver: request timed out" kind of errors, try to get pod status again before timeout.
|
||||
fmt.Println(errors.Wrap(err, fmt.Sprintf("Failed to verify pod %s/%s is %s, try again...\n", namespace, podName, corev1.PodRunning)))
|
||||
fmt.Println(errors.Wrap(err, fmt.Sprintf("Failed to verify pod %s/%s is %s, try again...\n", namespace, podName, corev1api.PodRunning)))
|
||||
return false, nil
|
||||
}
|
||||
// If any pod is still waiting we don't need to check any more so return and wait for next poll interval
|
||||
if checkPod.Status.Phase != corev1.PodRunning {
|
||||
fmt.Printf("Pod %s is in state %s waiting for it to be %s\n", podName, checkPod.Status.Phase, corev1.PodRunning)
|
||||
if checkPod.Status.Phase != corev1api.PodRunning {
|
||||
fmt.Printf("Pod %s is in state %s waiting for it to be %s\n", podName, checkPod.Status.Phase, corev1api.PodRunning)
|
||||
return false, nil
|
||||
}
|
||||
}
|
||||
@@ -284,12 +284,12 @@ func GetPVByPVCName(client TestClient, namespace, pvcName string) (string, error
|
||||
return pv_value.Name, nil
|
||||
}
|
||||
|
||||
func PrepareVolumeList(volumeNameList []string) (vols []*corev1.Volume) {
|
||||
func PrepareVolumeList(volumeNameList []string) (vols []*corev1api.Volume) {
|
||||
for i, volume := range volumeNameList {
|
||||
vols = append(vols, &corev1.Volume{
|
||||
vols = append(vols, &corev1api.Volume{
|
||||
Name: volume,
|
||||
VolumeSource: corev1.VolumeSource{
|
||||
PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{
|
||||
VolumeSource: corev1api.VolumeSource{
|
||||
PersistentVolumeClaim: &corev1api.PersistentVolumeClaimVolumeSource{
|
||||
ClaimName: fmt.Sprintf("pvc-%d", i),
|
||||
ReadOnly: false,
|
||||
},
|
||||
@@ -415,13 +415,13 @@ func GetAllService(ctx context.Context) (string, error) {
|
||||
return stdout, nil
|
||||
}
|
||||
|
||||
func CreateVolumes(pvcName string, volumeNameList []string) (vols []*corev1.Volume) {
|
||||
vols = []*corev1.Volume{}
|
||||
func CreateVolumes(pvcName string, volumeNameList []string) (vols []*corev1api.Volume) {
|
||||
vols = []*corev1api.Volume{}
|
||||
for _, volume := range volumeNameList {
|
||||
vols = append(vols, &corev1.Volume{
|
||||
vols = append(vols, &corev1api.Volume{
|
||||
Name: volume,
|
||||
VolumeSource: corev1.VolumeSource{
|
||||
PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{
|
||||
VolumeSource: corev1api.VolumeSource{
|
||||
PersistentVolumeClaim: &corev1api.PersistentVolumeClaimVolumeSource{
|
||||
ClaimName: pvcName,
|
||||
ReadOnly: false,
|
||||
},
|
||||
|
||||
@@ -23,7 +23,7 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
"golang.org/x/net/context"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
corev1api "k8s.io/api/core/v1"
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
@@ -31,8 +31,8 @@ import (
|
||||
clientset "k8s.io/client-go/kubernetes"
|
||||
)
|
||||
|
||||
func CreateConfigMap(c clientset.Interface, ns, name string, labels, data map[string]string) (*v1.ConfigMap, error) {
|
||||
cm := &v1.ConfigMap{
|
||||
func CreateConfigMap(c clientset.Interface, ns, name string, labels, data map[string]string) (*corev1api.ConfigMap, error) {
|
||||
cm := &corev1api.ConfigMap{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: name,
|
||||
Labels: labels,
|
||||
@@ -45,7 +45,7 @@ func CreateConfigMap(c clientset.Interface, ns, name string, labels, data map[st
|
||||
func CreateConfigMapFromYAMLData(c clientset.Interface, yamlData, cmName, namespace string) error {
|
||||
cmData := make(map[string]string)
|
||||
cmData[cmName] = yamlData
|
||||
cm := &v1.ConfigMap{
|
||||
cm := &corev1api.ConfigMap{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: cmName,
|
||||
Namespace: namespace,
|
||||
@@ -67,7 +67,7 @@ func WaitForConfigMapComplete(c clientset.Interface, ns, cmName string) error {
|
||||
})
|
||||
}
|
||||
|
||||
func GetConfigMap(c clientset.Interface, ns, secretName string) (*v1.ConfigMap, error) {
|
||||
func GetConfigMap(c clientset.Interface, ns, secretName string) (*corev1api.ConfigMap, error) {
|
||||
return c.CoreV1().ConfigMaps(ns).Get(context.TODO(), secretName, metav1.GetOptions{})
|
||||
}
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@ import (
|
||||
"time"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
apps "k8s.io/api/apps/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
appsv1api "k8s.io/api/apps/v1"
|
||||
corev1api "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
clientset "k8s.io/client-go/kubernetes"
|
||||
@@ -40,39 +40,39 @@ const (
|
||||
|
||||
// DeploymentBuilder builds Deployment objects.
|
||||
type DeploymentBuilder struct {
|
||||
*apps.Deployment
|
||||
*appsv1api.Deployment
|
||||
}
|
||||
|
||||
func (d *DeploymentBuilder) Result() *apps.Deployment {
|
||||
func (d *DeploymentBuilder) Result() *appsv1api.Deployment {
|
||||
return d.Deployment
|
||||
}
|
||||
|
||||
// newDeployment returns a RollingUpdate Deployment with a fake container image
|
||||
func NewDeployment(name, ns string, replicas int32, labels map[string]string, containers []v1.Container) *DeploymentBuilder {
|
||||
func NewDeployment(name, ns string, replicas int32, labels map[string]string, containers []corev1api.Container) *DeploymentBuilder {
|
||||
if containers == nil {
|
||||
containers = []v1.Container{
|
||||
containers = []corev1api.Container{
|
||||
{
|
||||
Name: DefaultContainerName,
|
||||
Image: "gcr.io/velero-gcp/busybox:latest",
|
||||
Command: []string{"sleep", "1000000"},
|
||||
// Make pod obeys the restricted pod security standards.
|
||||
SecurityContext: &v1.SecurityContext{
|
||||
SecurityContext: &corev1api.SecurityContext{
|
||||
AllowPrivilegeEscalation: boolptr.False(),
|
||||
Capabilities: &v1.Capabilities{
|
||||
Drop: []v1.Capability{"ALL"},
|
||||
Capabilities: &corev1api.Capabilities{
|
||||
Drop: []corev1api.Capability{"ALL"},
|
||||
},
|
||||
RunAsNonRoot: boolptr.True(),
|
||||
RunAsUser: func(i int64) *int64 { return &i }(65534),
|
||||
RunAsGroup: func(i int64) *int64 { return &i }(65534),
|
||||
SeccompProfile: &v1.SeccompProfile{
|
||||
Type: v1.SeccompProfileTypeRuntimeDefault,
|
||||
SeccompProfile: &corev1api.SeccompProfile{
|
||||
Type: corev1api.SeccompProfileTypeRuntimeDefault,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
return &DeploymentBuilder{
|
||||
&apps.Deployment{
|
||||
&appsv1api.Deployment{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
Kind: "Deployment",
|
||||
APIVersion: "apps/v1",
|
||||
@@ -82,21 +82,21 @@ func NewDeployment(name, ns string, replicas int32, labels map[string]string, co
|
||||
Name: name,
|
||||
Labels: labels,
|
||||
},
|
||||
Spec: apps.DeploymentSpec{
|
||||
Spec: appsv1api.DeploymentSpec{
|
||||
Replicas: &replicas,
|
||||
Selector: &metav1.LabelSelector{MatchLabels: labels},
|
||||
Strategy: apps.DeploymentStrategy{
|
||||
Type: apps.RollingUpdateDeploymentStrategyType,
|
||||
RollingUpdate: new(apps.RollingUpdateDeployment),
|
||||
Strategy: appsv1api.DeploymentStrategy{
|
||||
Type: appsv1api.RollingUpdateDeploymentStrategyType,
|
||||
RollingUpdate: new(appsv1api.RollingUpdateDeployment),
|
||||
},
|
||||
Template: v1.PodTemplateSpec{
|
||||
Template: corev1api.PodTemplateSpec{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Labels: labels,
|
||||
},
|
||||
Spec: v1.PodSpec{
|
||||
SecurityContext: &v1.PodSecurityContext{
|
||||
Spec: corev1api.PodSpec{
|
||||
SecurityContext: &corev1api.PodSecurityContext{
|
||||
FSGroup: func(i int64) *int64 { return &i }(65534),
|
||||
FSGroupChangePolicy: func(policy v1.PodFSGroupChangePolicy) *v1.PodFSGroupChangePolicy { return &policy }(v1.FSGroupChangeAlways),
|
||||
FSGroupChangePolicy: func(policy corev1api.PodFSGroupChangePolicy) *corev1api.PodFSGroupChangePolicy { return &policy }(corev1api.FSGroupChangeAlways),
|
||||
},
|
||||
Containers: containers,
|
||||
},
|
||||
@@ -106,10 +106,10 @@ func NewDeployment(name, ns string, replicas int32, labels map[string]string, co
|
||||
}
|
||||
}
|
||||
|
||||
func (d *DeploymentBuilder) WithVolume(volumes []*v1.Volume) *DeploymentBuilder {
|
||||
vmList := []v1.VolumeMount{}
|
||||
func (d *DeploymentBuilder) WithVolume(volumes []*corev1api.Volume) *DeploymentBuilder {
|
||||
vmList := []corev1api.VolumeMount{}
|
||||
for _, v := range volumes {
|
||||
vmList = append(vmList, v1.VolumeMount{
|
||||
vmList = append(vmList, corev1api.VolumeMount{
|
||||
Name: v.Name,
|
||||
MountPath: "/" + v.Name,
|
||||
})
|
||||
@@ -121,15 +121,15 @@ func (d *DeploymentBuilder) WithVolume(volumes []*v1.Volume) *DeploymentBuilder
|
||||
return d
|
||||
}
|
||||
|
||||
func CreateDeploy(c clientset.Interface, ns string, deployment *apps.Deployment) error {
|
||||
func CreateDeploy(c clientset.Interface, ns string, deployment *appsv1api.Deployment) error {
|
||||
_, err := c.AppsV1().Deployments(ns).Create(context.TODO(), deployment, metav1.CreateOptions{})
|
||||
return err
|
||||
}
|
||||
func CreateDeployment(c clientset.Interface, ns string, deployment *apps.Deployment) (*apps.Deployment, error) {
|
||||
func CreateDeployment(c clientset.Interface, ns string, deployment *appsv1api.Deployment) (*appsv1api.Deployment, error) {
|
||||
return c.AppsV1().Deployments(ns).Create(context.TODO(), deployment, metav1.CreateOptions{})
|
||||
}
|
||||
|
||||
func GetDeployment(c clientset.Interface, ns, name string) (*apps.Deployment, error) {
|
||||
func GetDeployment(c clientset.Interface, ns, name string) (*appsv1api.Deployment, error) {
|
||||
return c.AppsV1().Deployments(ns).Get(context.TODO(), name, metav1.GetOptions{})
|
||||
}
|
||||
|
||||
|
||||
@@ -21,24 +21,24 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
corev1api "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/api/resource"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/client-go/util/retry"
|
||||
)
|
||||
|
||||
func CreatePersistentVolume(client TestClient, name string) (*corev1.PersistentVolume, error) {
|
||||
p := &corev1.PersistentVolume{
|
||||
func CreatePersistentVolume(client TestClient, name string) (*corev1api.PersistentVolume, error) {
|
||||
p := &corev1api.PersistentVolume{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: name,
|
||||
},
|
||||
Spec: corev1.PersistentVolumeSpec{
|
||||
Spec: corev1api.PersistentVolumeSpec{
|
||||
StorageClassName: "manual",
|
||||
AccessModes: []corev1.PersistentVolumeAccessMode{corev1.ReadWriteOnce},
|
||||
Capacity: corev1.ResourceList{corev1.ResourceStorage: resource.MustParse("2Gi")},
|
||||
AccessModes: []corev1api.PersistentVolumeAccessMode{corev1api.ReadWriteOnce},
|
||||
Capacity: corev1api.ResourceList{corev1api.ResourceStorage: resource.MustParse("2Gi")},
|
||||
|
||||
PersistentVolumeSource: corev1.PersistentVolumeSource{
|
||||
HostPath: &corev1.HostPathVolumeSource{
|
||||
PersistentVolumeSource: corev1api.PersistentVolumeSource{
|
||||
HostPath: &corev1api.HostPathVolumeSource{
|
||||
Path: "/demo",
|
||||
},
|
||||
},
|
||||
@@ -48,11 +48,11 @@ func CreatePersistentVolume(client TestClient, name string) (*corev1.PersistentV
|
||||
return client.ClientGo.CoreV1().PersistentVolumes().Create(context.TODO(), p, metav1.CreateOptions{})
|
||||
}
|
||||
|
||||
func GetPersistentVolume(ctx context.Context, client TestClient, namespace string, persistentVolume string) (*corev1.PersistentVolume, error) {
|
||||
func GetPersistentVolume(ctx context.Context, client TestClient, namespace string, persistentVolume string) (*corev1api.PersistentVolume, error) {
|
||||
return client.ClientGo.CoreV1().PersistentVolumes().Get(ctx, persistentVolume, metav1.GetOptions{})
|
||||
}
|
||||
|
||||
func AddAnnotationToPersistentVolume(ctx context.Context, client TestClient, namespace string, persistentVolume, key string) (*corev1.PersistentVolume, error) {
|
||||
func AddAnnotationToPersistentVolume(ctx context.Context, client TestClient, namespace string, persistentVolume, key string) (*corev1api.PersistentVolume, error) {
|
||||
newPV, err := GetPersistentVolume(ctx, client, "", persistentVolume)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, fmt.Sprintf("Fail to ge PV %s", persistentVolume))
|
||||
@@ -73,7 +73,7 @@ func ClearClaimRefForFailedPVs(ctx context.Context, client TestClient) error {
|
||||
for _, pv := range pvList.Items {
|
||||
pvName := pv.Name
|
||||
|
||||
if pv.Status.Phase != corev1.VolumeAvailable {
|
||||
if pv.Status.Phase != corev1api.VolumeAvailable {
|
||||
retryErr := retry.RetryOnConflict(retry.DefaultRetry, func() error {
|
||||
pv, getErr := client.ClientGo.CoreV1().PersistentVolumes().Get(ctx, pvName, metav1.GetOptions{})
|
||||
if getErr != nil {
|
||||
|
||||
@@ -21,18 +21,17 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
corev1api "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/vmware-tanzu/velero/pkg/util/boolptr"
|
||||
)
|
||||
|
||||
func CreatePod(client TestClient, ns, name, sc, pvcName string, volumeNameList []string, pvcAnn, ann map[string]string) (*corev1.Pod, error) {
|
||||
func CreatePod(client TestClient, ns, name, sc, pvcName string, volumeNameList []string, pvcAnn, ann map[string]string) (*corev1api.Pod, error) {
|
||||
if pvcName != "" && len(volumeNameList) != 1 {
|
||||
return nil, errors.New("Volume name list should contain only 1 since PVC name is not empty")
|
||||
}
|
||||
volumes := []corev1.Volume{}
|
||||
volumes := []corev1api.Volume{}
|
||||
for _, volume := range volumeNameList {
|
||||
var _pvcName string
|
||||
if pvcName == "" {
|
||||
@@ -45,10 +44,10 @@ func CreatePod(client TestClient, ns, name, sc, pvcName string, volumeNameList [
|
||||
return nil, err
|
||||
}
|
||||
|
||||
volumes = append(volumes, corev1.Volume{
|
||||
volumes = append(volumes, corev1api.Volume{
|
||||
Name: volume,
|
||||
VolumeSource: corev1.VolumeSource{
|
||||
PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{
|
||||
VolumeSource: corev1api.VolumeSource{
|
||||
PersistentVolumeClaim: &corev1api.PersistentVolumeClaimVolumeSource{
|
||||
ClaimName: pvc.Name,
|
||||
ReadOnly: false,
|
||||
},
|
||||
@@ -56,41 +55,41 @@ func CreatePod(client TestClient, ns, name, sc, pvcName string, volumeNameList [
|
||||
})
|
||||
}
|
||||
|
||||
vmList := []corev1.VolumeMount{}
|
||||
vmList := []corev1api.VolumeMount{}
|
||||
for _, v := range volumes {
|
||||
vmList = append(vmList, corev1.VolumeMount{
|
||||
vmList = append(vmList, corev1api.VolumeMount{
|
||||
Name: v.Name,
|
||||
MountPath: "/" + v.Name,
|
||||
})
|
||||
}
|
||||
|
||||
p := &corev1.Pod{
|
||||
p := &corev1api.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: name,
|
||||
Annotations: ann,
|
||||
},
|
||||
Spec: corev1.PodSpec{
|
||||
SecurityContext: &v1.PodSecurityContext{
|
||||
Spec: corev1api.PodSpec{
|
||||
SecurityContext: &corev1api.PodSecurityContext{
|
||||
FSGroup: func(i int64) *int64 { return &i }(65534),
|
||||
FSGroupChangePolicy: func(policy v1.PodFSGroupChangePolicy) *v1.PodFSGroupChangePolicy { return &policy }(v1.FSGroupChangeAlways),
|
||||
FSGroupChangePolicy: func(policy corev1api.PodFSGroupChangePolicy) *corev1api.PodFSGroupChangePolicy { return &policy }(corev1api.FSGroupChangeAlways),
|
||||
},
|
||||
Containers: []corev1.Container{
|
||||
Containers: []corev1api.Container{
|
||||
{
|
||||
Name: name,
|
||||
Image: "gcr.io/velero-gcp/busybox",
|
||||
Command: []string{"sleep", "3600"},
|
||||
VolumeMounts: vmList,
|
||||
// Make pod obeys the restricted pod security standards.
|
||||
SecurityContext: &v1.SecurityContext{
|
||||
SecurityContext: &corev1api.SecurityContext{
|
||||
AllowPrivilegeEscalation: boolptr.False(),
|
||||
Capabilities: &v1.Capabilities{
|
||||
Drop: []v1.Capability{"ALL"},
|
||||
Capabilities: &corev1api.Capabilities{
|
||||
Drop: []corev1api.Capability{"ALL"},
|
||||
},
|
||||
RunAsNonRoot: boolptr.True(),
|
||||
RunAsUser: func(i int64) *int64 { return &i }(65534),
|
||||
RunAsGroup: func(i int64) *int64 { return &i }(65534),
|
||||
SeccompProfile: &v1.SeccompProfile{
|
||||
Type: v1.SeccompProfileTypeRuntimeDefault,
|
||||
SeccompProfile: &corev1api.SeccompProfile{
|
||||
Type: corev1api.SeccompProfileTypeRuntimeDefault,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -102,11 +101,11 @@ func CreatePod(client TestClient, ns, name, sc, pvcName string, volumeNameList [
|
||||
return client.ClientGo.CoreV1().Pods(ns).Create(context.TODO(), p, metav1.CreateOptions{})
|
||||
}
|
||||
|
||||
func GetPod(ctx context.Context, client TestClient, namespace string, pod string) (*corev1.Pod, error) {
|
||||
func GetPod(ctx context.Context, client TestClient, namespace string, pod string) (*corev1api.Pod, error) {
|
||||
return client.ClientGo.CoreV1().Pods(namespace).Get(ctx, pod, metav1.GetOptions{})
|
||||
}
|
||||
|
||||
func AddAnnotationToPod(ctx context.Context, client TestClient, namespace, podName string, ann map[string]string) (*corev1.Pod, error) {
|
||||
func AddAnnotationToPod(ctx context.Context, client TestClient, namespace, podName string, ann map[string]string) (*corev1api.Pod, error) {
|
||||
newPod, err := GetPod(ctx, client, namespace, podName)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, fmt.Sprintf("Fail to ge pod %s in namespace %s", podName, namespace))
|
||||
@@ -125,6 +124,6 @@ func AddAnnotationToPod(ctx context.Context, client TestClient, namespace, podNa
|
||||
return client.ClientGo.CoreV1().Pods(namespace).Update(ctx, newPod, metav1.UpdateOptions{})
|
||||
}
|
||||
|
||||
func ListPods(ctx context.Context, client TestClient, namespace string) (*corev1.PodList, error) {
|
||||
func ListPods(ctx context.Context, client TestClient, namespace string) (*corev1api.PodList, error) {
|
||||
return client.ClientGo.CoreV1().Pods(namespace).List(ctx, metav1.ListOptions{})
|
||||
}
|
||||
|
||||
@@ -19,32 +19,32 @@ package k8s
|
||||
import (
|
||||
"context"
|
||||
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
corev1api "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/api/resource"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
// PVCBuilder builds PVC objects.
|
||||
type PVCBuilder struct {
|
||||
*corev1.PersistentVolumeClaim
|
||||
*corev1api.PersistentVolumeClaim
|
||||
}
|
||||
|
||||
func (p *PVCBuilder) Result() *corev1.PersistentVolumeClaim {
|
||||
func (p *PVCBuilder) Result() *corev1api.PersistentVolumeClaim {
|
||||
return p.PersistentVolumeClaim
|
||||
}
|
||||
|
||||
func NewPVC(ns, name string) *PVCBuilder {
|
||||
oMeta := metav1.ObjectMeta{Name: name, Namespace: ns}
|
||||
return &PVCBuilder{
|
||||
&corev1.PersistentVolumeClaim{
|
||||
&corev1api.PersistentVolumeClaim{
|
||||
ObjectMeta: oMeta,
|
||||
Spec: corev1.PersistentVolumeClaimSpec{
|
||||
AccessModes: []corev1.PersistentVolumeAccessMode{
|
||||
corev1.ReadWriteOnce, // Default read write once
|
||||
Spec: corev1api.PersistentVolumeClaimSpec{
|
||||
AccessModes: []corev1api.PersistentVolumeAccessMode{
|
||||
corev1api.ReadWriteOnce, // Default read write once
|
||||
},
|
||||
Resources: corev1.VolumeResourceRequirements{
|
||||
Requests: corev1.ResourceList{
|
||||
corev1.ResourceStorage: resource.MustParse("1Gi"), // Default 1Gi
|
||||
Resources: corev1api.VolumeResourceRequirements{
|
||||
Requests: corev1api.ResourceList{
|
||||
corev1api.ResourceStorage: resource.MustParse("1Gi"), // Default 1Gi
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -63,11 +63,11 @@ func (p *PVCBuilder) WithStorageClass(sc string) *PVCBuilder {
|
||||
}
|
||||
|
||||
func (p *PVCBuilder) WithResourceStorage(q resource.Quantity) *PVCBuilder {
|
||||
p.Spec.Resources.Requests[corev1.ResourceStorage] = q
|
||||
p.Spec.Resources.Requests[corev1api.ResourceStorage] = q
|
||||
return p
|
||||
}
|
||||
|
||||
func CreatePVC(client TestClient, ns, name, sc string, ann map[string]string) (*corev1.PersistentVolumeClaim, error) {
|
||||
func CreatePVC(client TestClient, ns, name, sc string, ann map[string]string) (*corev1api.PersistentVolumeClaim, error) {
|
||||
pvcBulder := NewPVC(ns, name)
|
||||
if ann != nil {
|
||||
pvcBulder.WithAnnotation(ann)
|
||||
@@ -84,6 +84,6 @@ func CreatePvc(client TestClient, pvcBulder *PVCBuilder) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func GetPVC(ctx context.Context, client TestClient, namespace string, pvcName string) (*corev1.PersistentVolumeClaim, error) {
|
||||
func GetPVC(ctx context.Context, client TestClient, namespace string, pvcName string) (*corev1api.PersistentVolumeClaim, error) {
|
||||
return client.ClientGo.CoreV1().PersistentVolumeClaims(namespace).Get(ctx, pvcName, metav1.GetOptions{})
|
||||
}
|
||||
|
||||
@@ -22,13 +22,13 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
v1 "k8s.io/api/rbac/v1"
|
||||
rbacv1 "k8s.io/api/rbac/v1"
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
func CreateRBACWithBindingSA(ctx context.Context, client TestClient, namespace string, serviceaccount string, clusterrole string, clusterrolebinding string) error {
|
||||
role := &v1.ClusterRole{
|
||||
role := &rbacv1.ClusterRole{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: clusterrole,
|
||||
},
|
||||
@@ -41,18 +41,18 @@ func CreateRBACWithBindingSA(ctx context.Context, client TestClient, namespace s
|
||||
}
|
||||
|
||||
//creating role binding and binding it to the test service account
|
||||
rolebinding := &v1.ClusterRoleBinding{
|
||||
rolebinding := &rbacv1.ClusterRoleBinding{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: clusterrolebinding,
|
||||
},
|
||||
Subjects: []v1.Subject{
|
||||
Subjects: []rbacv1.Subject{
|
||||
{
|
||||
Kind: "ServiceAccount",
|
||||
Name: serviceaccount,
|
||||
Namespace: namespace,
|
||||
},
|
||||
},
|
||||
RoleRef: v1.RoleRef{
|
||||
RoleRef: rbacv1.RoleRef{
|
||||
Kind: "ClusterRole",
|
||||
Name: clusterrole,
|
||||
},
|
||||
@@ -67,11 +67,11 @@ func CreateRBACWithBindingSA(ctx context.Context, client TestClient, namespace s
|
||||
return nil
|
||||
}
|
||||
|
||||
func GetClusterRole(ctx context.Context, client TestClient, role string) (*v1.ClusterRole, error) {
|
||||
func GetClusterRole(ctx context.Context, client TestClient, role string) (*rbacv1.ClusterRole, error) {
|
||||
return client.ClientGo.RbacV1().ClusterRoles().Get(ctx, role, metav1.GetOptions{})
|
||||
}
|
||||
|
||||
func GetClusterRoleBinding(ctx context.Context, client TestClient, rolebinding string) (*v1.ClusterRoleBinding, error) {
|
||||
func GetClusterRoleBinding(ctx context.Context, client TestClient, rolebinding string) (*rbacv1.ClusterRoleBinding, error) {
|
||||
return client.ClientGo.RbacV1().ClusterRoleBindings().Get(ctx, rolebinding, metav1.GetOptions{})
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
func InstallStorageClass(ctx context.Context, yaml string) error {
|
||||
@@ -15,7 +15,7 @@ func InstallStorageClass(ctx context.Context, yaml string) error {
|
||||
}
|
||||
|
||||
func DeleteStorageClass(ctx context.Context, client TestClient, name string) error {
|
||||
if err := client.ClientGo.StorageV1().StorageClasses().Delete(ctx, name, v1.DeleteOptions{}); err != nil {
|
||||
if err := client.ClientGo.StorageV1().StorageClasses().Delete(ctx, name, metav1.DeleteOptions{}); err != nil {
|
||||
return errors.Wrapf(err, "Could not retrieve storage classes %s", name)
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -23,7 +23,7 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
"golang.org/x/net/context"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
corev1api "k8s.io/api/core/v1"
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
@@ -31,8 +31,8 @@ import (
|
||||
clientset "k8s.io/client-go/kubernetes"
|
||||
)
|
||||
|
||||
func CreateSecret(c clientset.Interface, ns, name string, labels map[string]string) (*v1.Secret, error) {
|
||||
secret := &v1.Secret{
|
||||
func CreateSecret(c clientset.Interface, ns, name string, labels map[string]string) (*corev1api.Secret, error) {
|
||||
secret := &corev1api.Secret{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: name,
|
||||
Labels: labels,
|
||||
@@ -69,6 +69,6 @@ func WaitForSecretsComplete(c clientset.Interface, ns, secretName string) error
|
||||
})
|
||||
}
|
||||
|
||||
func GetSecret(c clientset.Interface, ns, secretName string) (*v1.Secret, error) {
|
||||
func GetSecret(c clientset.Interface, ns, secretName string) (*corev1api.Secret, error) {
|
||||
return c.CoreV1().Secrets(ns).Get(context.TODO(), secretName, metav1.GetOptions{})
|
||||
}
|
||||
|
||||
@@ -23,15 +23,15 @@ import (
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
corev1api "k8s.io/api/core/v1"
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
waitutil "k8s.io/apimachinery/pkg/util/wait"
|
||||
)
|
||||
|
||||
func CreateService(ctx context.Context, client TestClient, namespace string,
|
||||
service string, labels map[string]string, serviceSpec *corev1.ServiceSpec) error {
|
||||
se := &corev1.Service{
|
||||
service string, labels map[string]string, serviceSpec *corev1api.ServiceSpec) error {
|
||||
se := &corev1api.Service{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
Kind: "Service",
|
||||
APIVersion: "apps/v1",
|
||||
@@ -51,7 +51,7 @@ func CreateService(ctx context.Context, client TestClient, namespace string,
|
||||
return nil
|
||||
}
|
||||
|
||||
func GetService(ctx context.Context, client TestClient, namespace string, service string) (*corev1.Service, error) {
|
||||
func GetService(ctx context.Context, client TestClient, namespace string, service string) (*corev1api.Service, error) {
|
||||
return client.ClientGo.CoreV1().Services(namespace).Get(ctx, service, metav1.GetOptions{})
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
corev1api "k8s.io/api/core/v1"
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
@@ -60,7 +60,7 @@ func PatchServiceAccountWithImagePullSecret(ctx context.Context, client TestClie
|
||||
}
|
||||
secretName := "image-pull-secret"
|
||||
secret := builder.ForSecret(namespace, secretName).Data(map[string][]byte{".dockerconfigjson": credential}).Result()
|
||||
secret.Type = corev1.SecretTypeDockerConfigJson
|
||||
secret.Type = corev1api.SecretTypeDockerConfigJson
|
||||
if _, err = client.ClientGo.CoreV1().Secrets(namespace).Create(ctx, secret, metav1.CreateOptions{}); err != nil {
|
||||
return errors.Wrapf(err, "failed to create secret %q under namespace %q", secretName, namespace)
|
||||
}
|
||||
@@ -73,7 +73,7 @@ func PatchServiceAccountWithImagePullSecret(ctx context.Context, client TestClie
|
||||
}
|
||||
|
||||
func CreateServiceAccount(ctx context.Context, client TestClient, namespace string, serviceaccount string) error {
|
||||
sa := &corev1.ServiceAccount{
|
||||
sa := &corev1api.ServiceAccount{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: serviceaccount,
|
||||
},
|
||||
@@ -88,6 +88,6 @@ func CreateServiceAccount(ctx context.Context, client TestClient, namespace stri
|
||||
return nil
|
||||
}
|
||||
|
||||
func GetServiceAccount(ctx context.Context, client TestClient, namespace string, serviceAccount string) (*corev1.ServiceAccount, error) {
|
||||
func GetServiceAccount(ctx context.Context, client TestClient, namespace string, serviceAccount string) (*corev1api.ServiceAccount, error) {
|
||||
return client.ClientGo.CoreV1().ServiceAccounts(namespace).Get(context.TODO(), serviceAccount, metav1.GetOptions{})
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
corev1api "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/api/resource"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
@@ -50,8 +50,8 @@ func GetPodUsageMetrics(ctx context.Context, metricsClient *metricsclientset.Cli
|
||||
// Variables to store the max and sum of CPU and memory usage
|
||||
// For velero pod we only return the main container
|
||||
for _, container := range podMetrics.Containers {
|
||||
cpuUsage = container.Usage[corev1.ResourceCPU]
|
||||
memoryUsage = container.Usage[corev1.ResourceMemory]
|
||||
cpuUsage = container.Usage[corev1api.ResourceCPU]
|
||||
memoryUsage = container.Usage[corev1api.ResourceMemory]
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -28,8 +28,8 @@ import (
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/exp/slices"
|
||||
apps "k8s.io/api/apps/v1"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
appsv1api "k8s.io/api/apps/v1"
|
||||
corev1api "k8s.io/api/core/v1"
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||
@@ -478,8 +478,8 @@ func createVeleroResources(ctx context.Context, cli, namespace string, args []st
|
||||
func patchResources(resources *unstructured.UnstructuredList, namespace string, options *installOptions) error {
|
||||
i := 0
|
||||
size := 2
|
||||
var deploy apps.Deployment
|
||||
var imagePullSecret corev1.Secret
|
||||
var deploy appsv1api.Deployment
|
||||
var imagePullSecret corev1api.Secret
|
||||
|
||||
for resourceIndex, resource := range resources.Items {
|
||||
// apply the image pull secret to avoid the image pull limit of Docker Hub
|
||||
@@ -489,16 +489,16 @@ func patchResources(resources *unstructured.UnstructuredList, namespace string,
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to read the registry credential file %s", options.RegistryCredentialFile)
|
||||
}
|
||||
imagePullSecret = corev1.Secret{
|
||||
imagePullSecret = corev1api.Secret{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
Kind: "Secret",
|
||||
APIVersion: corev1.SchemeGroupVersion.String(),
|
||||
APIVersion: corev1api.SchemeGroupVersion.String(),
|
||||
},
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "image-pull-secret",
|
||||
Namespace: namespace,
|
||||
},
|
||||
Type: corev1.SecretTypeDockerConfigJson,
|
||||
Type: corev1api.SecretTypeDockerConfigJson,
|
||||
Data: map[string][]byte{
|
||||
".dockerconfigjson": credential,
|
||||
},
|
||||
@@ -555,10 +555,10 @@ func patchResources(resources *unstructured.UnstructuredList, namespace string,
|
||||
|
||||
// customize the restic restore helper image
|
||||
if len(options.RestoreHelperImage) > 0 {
|
||||
restoreActionConfig := corev1.ConfigMap{
|
||||
restoreActionConfig := corev1api.ConfigMap{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
Kind: "ConfigMap",
|
||||
APIVersion: corev1.SchemeGroupVersion.String(),
|
||||
APIVersion: corev1api.SchemeGroupVersion.String(),
|
||||
},
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "restic-restore-action-config",
|
||||
@@ -612,7 +612,7 @@ func waitVeleroReady(ctx context.Context, namespace string, useNodeAgent bool) e
|
||||
if err != nil {
|
||||
return false, errors.Wrapf(err, "failed to get the node-agent daemonset, stdout=%s, stderr=%s", stdout, stderr)
|
||||
}
|
||||
daemonset := &apps.DaemonSet{}
|
||||
daemonset := &appsv1api.DaemonSet{}
|
||||
if err = json.Unmarshal([]byte(stdout), daemonset); err != nil {
|
||||
return false, errors.Wrapf(err, "failed to unmarshal the node-agent daemonset")
|
||||
}
|
||||
@@ -639,7 +639,7 @@ func IsVeleroReady(ctx context.Context, veleroCfg *test.VeleroConfig) (bool, err
|
||||
if err != nil {
|
||||
return false, errors.Wrapf(err, "failed to get the node-agent daemonset, stdout=%s, stderr=%s", stdout, stderr)
|
||||
} else {
|
||||
daemonset := &apps.DaemonSet{}
|
||||
daemonset := &appsv1api.DaemonSet{}
|
||||
if err = json.Unmarshal([]byte(stdout), daemonset); err != nil {
|
||||
return false, errors.Wrapf(err, "failed to unmarshal the node-agent daemonset")
|
||||
}
|
||||
@@ -654,7 +654,7 @@ func IsVeleroReady(ctx context.Context, veleroCfg *test.VeleroConfig) (bool, err
|
||||
if err != nil {
|
||||
return false, errors.Wrapf(err, "failed to get the velero deployment stdout=%s, stderr=%s", stdout, stderr)
|
||||
} else {
|
||||
deployment := &apps.Deployment{}
|
||||
deployment := &appsv1api.Deployment{}
|
||||
if err = json.Unmarshal([]byte(stdout), deployment); err != nil {
|
||||
return false, errors.Wrapf(err, "failed to unmarshal the velero deployment")
|
||||
}
|
||||
@@ -737,12 +737,12 @@ func createVCCredentialSecret(c clientset.Interface, veleroNamespace string) err
|
||||
return errors.New("failed to retrieve csi-vsphere config")
|
||||
}
|
||||
|
||||
vsphereSecret := &corev1.Secret{
|
||||
vsphereSecret := &corev1api.Secret{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "velero-vsphere-config-secret",
|
||||
Namespace: veleroNamespace,
|
||||
},
|
||||
Type: corev1.SecretTypeOpaque,
|
||||
Type: corev1api.SecretTypeOpaque,
|
||||
Data: map[string][]byte{"csi-vsphere.conf": vsphereCfg},
|
||||
}
|
||||
_, err = c.CoreV1().Secrets(veleroNamespace).Create(
|
||||
@@ -770,7 +770,7 @@ func createVCCredentialSecret(c clientset.Interface, veleroNamespace string) err
|
||||
|
||||
// Reference https://github.com/vmware-tanzu/velero-plugin-for-vsphere/blob/main/docs/vanilla.md#create-vc-credential-secret
|
||||
// Read secret from kube-system namespace first, if not found, try with vmware-system-csi.
|
||||
func getVCCredentialSecret(c clientset.Interface) (secret *corev1.Secret, err error) {
|
||||
func getVCCredentialSecret(c clientset.Interface) (secret *corev1api.Secret, err error) {
|
||||
secret, err = k8s.GetSecret(c, test.KubeSystemNamespace, "vsphere-config-secret")
|
||||
if err != nil {
|
||||
if apierrors.IsNotFound(err) {
|
||||
|
||||
Reference in New Issue
Block a user