mirror of
https://github.com/redhat-developer/odo.git
synced 2025-10-19 03:06:19 +03:00
* Initial commit Signed-off-by: Parthvi Vala <pvala@redhat.com> * Move ValidateResourceExist(s) from pkg/service to pkg/devfile/adapters/kubernetes/component * Fix odo dev cleanup * Fix multiple deployment issue Signed-off-by: Parthvi Vala <pvala@redhat.com> * DRY the code * Fix unit test failure * Add integration tests Signed-off-by: Parthvi Vala <pvala@redhat.com> * remove comment * Add isPartOfComponent to GetLabels, and GetSelector * Add unit tests for changes in ListResourcesToDeleteFromDevfile Signed-off-by: Parthvi Vala <pvala@redhat.com> * Fix unit test failures due to removal of component label * Enhance integration tests Signed-off-by: Parthvi Vala <pvala@redhat.com> * Use a single devfile.yaml * Fix test failures Signed-off-by: Parthvi Vala <pvala@redhat.com> * Fix rebase conflicts, add new tests for remote Dockerfile URI, and rm3l's review Signed-off-by: Parthvi Vala <pvala@redhat.com> Co-authored-by: Parthvi Vala <pvala@redhat.com> Co-authored-by: Armel Soro <armel@rm3l.org> Signed-off-by: Parthvi Vala <pvala@redhat.com> * Attempt at fixing integration tests Signed-off-by: Parthvi Vala <pvala@redhat.com> * Fix integration tests Signed-off-by: Parthvi Vala <pvala@redhat.com> * Mockgen * Changes post rebase Signed-off-by: Parthvi Vala <pvala@redhat.com> * Attempt at fixing integration tests Signed-off-by: Parthvi Vala <pvala@redhat.com> * Fix rebase mishap Signed-off-by: Parthvi Vala <pvala@redhat.com> Co-authored-by: Armel Soro <armel@rm3l.org>
48 lines
1.7 KiB
Go
48 lines
1.7 KiB
Go
package testingutil
|
|
|
|
import (
|
|
appsv1 "k8s.io/api/apps/v1"
|
|
corev1 "k8s.io/api/core/v1"
|
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
"k8s.io/apimachinery/pkg/types"
|
|
|
|
odolabels "github.com/redhat-developer/odo/pkg/labels"
|
|
)
|
|
|
|
// CreateFakeDeployment creates a fake deployment with the given pod name and labels
|
|
// isPartOfComponent bool decides if the deployment is supposed to be a part of the core resources deployed by `odo dev`
|
|
func CreateFakeDeployment(podName string, isPartOfComponent bool) *appsv1.Deployment {
|
|
fakeUID := types.UID("12345")
|
|
labels := odolabels.Builder().
|
|
WithApp("app").
|
|
WithAppName("app").
|
|
WithComponentName(podName).
|
|
WithManager("odo").
|
|
WithMode(odolabels.ComponentDevMode)
|
|
if isPartOfComponent {
|
|
labels = labels.WithComponent(podName)
|
|
}
|
|
deployment := appsv1.Deployment{
|
|
TypeMeta: metav1.TypeMeta{
|
|
Kind: "Deployment",
|
|
APIVersion: "apps/v1",
|
|
},
|
|
ObjectMeta: metav1.ObjectMeta{
|
|
Name: podName,
|
|
UID: fakeUID,
|
|
Labels: labels.Labels(),
|
|
Annotations: odolabels.Builder().WithProjectType(podName).Labels(),
|
|
},
|
|
}
|
|
return &deployment
|
|
}
|
|
|
|
// CreateFakeDeploymentsWithContainers creates a fake pod with the given pod name, container name and containers
|
|
// isPartOfComponent bool decides if the deployment is supposed to be a part of the core resources deployed by `odo dev`
|
|
func CreateFakeDeploymentsWithContainers(podName string, containers []corev1.Container, initContainers []corev1.Container, isPartOfComponent bool) *appsv1.Deployment {
|
|
fakeDeployment := CreateFakeDeployment(podName, isPartOfComponent)
|
|
fakeDeployment.Spec.Template.Spec.Containers = containers
|
|
fakeDeployment.Spec.Template.Spec.InitContainers = initContainers
|
|
return fakeDeployment
|
|
}
|