mirror of
https://github.com/kubevela/kubevela.git
synced 2026-08-27 16:17:34 +00:00
fix some tests
This commit is contained in:
+7
@@ -102,6 +102,13 @@ func (r *Reconciler) Reconcile(request reconcile.Request) (reconcile.Result, err
|
||||
// the name of the appConfig has to be the same as the appContext
|
||||
appConfig.Name = appContext.Name
|
||||
appConfig.UID = appContext.UID
|
||||
for _, owner := range appContext.GetOwnerReferences() {
|
||||
// if the appContext is created by Application, set the AppConfig UID to align with the application
|
||||
if owner.Kind == v1beta1.ApplicationKind {
|
||||
appConfig.UID = owner.UID
|
||||
break
|
||||
}
|
||||
}
|
||||
appConfig.SetLabels(appContext.GetLabels())
|
||||
appConfig.SetAnnotations(appContext.GetAnnotations())
|
||||
// makes sure that the appConfig's owner is the same as the appContext
|
||||
|
||||
+28
-14
@@ -27,6 +27,8 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/oam-dev/kubevela/apis/core.oam.dev/v1beta1"
|
||||
|
||||
cpv1alpha1 "github.com/crossplane/crossplane-runtime/apis/core/v1alpha1"
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
"github.com/go-logr/logr"
|
||||
@@ -132,25 +134,37 @@ type ConditionedObject interface {
|
||||
|
||||
// LocateParentAppConfig locate the parent application configuration object
|
||||
func LocateParentAppConfig(ctx context.Context, client client.Client, oamObject oam.Object) (oam.Object, error) {
|
||||
var acName string
|
||||
var eventObj = &v1alpha2.ApplicationConfiguration{}
|
||||
|
||||
// locate the appConf name from the owner list
|
||||
for _, o := range oamObject.GetOwnerReferences() {
|
||||
// TODO(wonderflow): this function maybe not work in the case AC was created by Application and the Application is the ownerRef here.
|
||||
if o.Kind == v1alpha2.ApplicationConfigurationKind {
|
||||
acName = o.Name
|
||||
break
|
||||
var eventObj = &v1alpha2.ApplicationConfiguration{}
|
||||
acName := o.Name
|
||||
if len(acName) > 0 {
|
||||
nn := types.NamespacedName{
|
||||
Name: acName,
|
||||
Namespace: oamObject.GetNamespace(),
|
||||
}
|
||||
if err := client.Get(ctx, nn, eventObj); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return eventObj, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(acName) > 0 {
|
||||
nn := types.NamespacedName{
|
||||
Name: acName,
|
||||
Namespace: oamObject.GetNamespace(),
|
||||
if o.Kind == v1beta1.ApplicationKind {
|
||||
var eventObj = &v1beta1.Application{}
|
||||
appName := o.Name
|
||||
if len(appName) > 0 {
|
||||
nn := types.NamespacedName{
|
||||
Name: appName,
|
||||
Namespace: oamObject.GetNamespace(),
|
||||
}
|
||||
if err := client.Get(ctx, nn, eventObj); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return eventObj, nil
|
||||
}
|
||||
}
|
||||
if err := client.Get(ctx, nn, eventObj); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return eventObj, nil
|
||||
}
|
||||
return nil, errors.Errorf(ErrLocateAppConfig)
|
||||
}
|
||||
|
||||
@@ -25,11 +25,6 @@ import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"github.com/oam-dev/kubevela/apis/core.oam.dev/common"
|
||||
"github.com/oam-dev/kubevela/apis/core.oam.dev/v1alpha2"
|
||||
"github.com/oam-dev/kubevela/apis/core.oam.dev/v1beta1"
|
||||
"github.com/oam-dev/kubevela/pkg/oam"
|
||||
"github.com/oam-dev/kubevela/pkg/oam/util"
|
||||
appsv1 "k8s.io/api/apps/v1"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
@@ -38,6 +33,12 @@ import (
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
"sigs.k8s.io/yaml"
|
||||
|
||||
"github.com/oam-dev/kubevela/apis/core.oam.dev/common"
|
||||
"github.com/oam-dev/kubevela/apis/core.oam.dev/v1alpha2"
|
||||
"github.com/oam-dev/kubevela/apis/core.oam.dev/v1beta1"
|
||||
"github.com/oam-dev/kubevela/pkg/oam"
|
||||
"github.com/oam-dev/kubevela/pkg/oam/util"
|
||||
)
|
||||
|
||||
var _ = Describe("Test application cross namespace resource", func() {
|
||||
@@ -240,7 +241,7 @@ var _ = Describe("Test application cross namespace resource", func() {
|
||||
return fmt.Errorf("error workload number %v", err)
|
||||
}
|
||||
workload := depolys.Items[0]
|
||||
if len(workload.OwnerReferences) != 1 || workload.OwnerReferences[0].Kind != v1alpha2.ApplicationConfigurationKind {
|
||||
if len(workload.OwnerReferences) != 1 || workload.OwnerReferences[0].Kind != v1beta1.ApplicationKind {
|
||||
return fmt.Errorf("workload owneRefernece err")
|
||||
}
|
||||
err = k8sClient.Get(ctx, generateResourceTrackerKey(app.Namespace, app.Name), resourceTracker)
|
||||
|
||||
@@ -182,7 +182,7 @@ var _ = Describe("Cloneset based rollout tests", func() {
|
||||
}
|
||||
return ""
|
||||
},
|
||||
time.Second*30, time.Millisecond*500).Should(BeEquivalentTo(v1alpha2.ApplicationConfigurationKind))
|
||||
time.Second*30, time.Millisecond*500).Should(BeEquivalentTo(v1beta1.ApplicationKind))
|
||||
Expect(clonesetOwner.Name).Should(BeEquivalentTo(targetAppName))
|
||||
Expect(kc.Status.UpdatedReplicas).Should(BeEquivalentTo(*kc.Spec.Replicas))
|
||||
Expect(kc.Status.UpdatedReadyReplicas).Should(BeEquivalentTo(*kc.Spec.Replicas))
|
||||
|
||||
Reference in New Issue
Block a user