Skip to content

Commit be20100

Browse files
authored
chore: pkg import only once (#3120)
Signed-off-by: guoguangwu <[email protected]>
1 parent 09046e9 commit be20100

File tree

2 files changed

+30
-28
lines changed

2 files changed

+30
-28
lines changed

Diff for: test/e2e/catalog_e2e_test.go

+5-6
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414
"time"
1515

1616
operatorsv1 "github.com/operator-framework/api/pkg/operators/v1"
17-
operatorsv1alpha1 "github.com/operator-framework/api/pkg/operators/v1alpha1"
1817
packageserverclientset "github.com/operator-framework/operator-lifecycle-manager/pkg/package-server/client/clientset/versioned"
1918
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
2019
k8serror "k8s.io/apimachinery/pkg/api/errors"
@@ -1421,7 +1420,7 @@ var _ = Describe("Starting CatalogSource e2e tests", func() {
14211420
var (
14221421
magicCatalog *MagicCatalog
14231422
catalogSourceName string
1424-
subscription *operatorsv1alpha1.Subscription
1423+
subscription *v1alpha1.Subscription
14251424
c client.Client
14261425
)
14271426

@@ -1444,12 +1443,12 @@ var _ = Describe("Starting CatalogSource e2e tests", func() {
14441443
When("A Subscription is created catalogSource built with the malformed CSV", func() {
14451444

14461445
BeforeEach(func() {
1447-
subscription = &operatorsv1alpha1.Subscription{
1446+
subscription = &v1alpha1.Subscription{
14481447
ObjectMeta: metav1.ObjectMeta{
14491448
Name: fmt.Sprintf("%s-sub", catalogSourceName),
14501449
Namespace: generatedNamespace.GetName(),
14511450
},
1452-
Spec: &operatorsv1alpha1.SubscriptionSpec{
1451+
Spec: &v1alpha1.SubscriptionSpec{
14531452
CatalogSource: catalogSourceName,
14541453
CatalogSourceNamespace: generatedNamespace.GetName(),
14551454
Channel: "stable",
@@ -1514,7 +1513,7 @@ var _ = Describe("Starting CatalogSource e2e tests", func() {
15141513
SourceType: v1alpha1.SourceTypeGrpc,
15151514
Image: "quay.io/olmtest/old-opm-catsrc:v1.21.0",
15161515
GrpcPodConfig: &v1alpha1.GrpcPodConfig{
1517-
SecurityContextConfig: operatorsv1alpha1.Restricted,
1516+
SecurityContextConfig: v1alpha1.Restricted,
15181517
},
15191518
},
15201519
}
@@ -1585,7 +1584,7 @@ var _ = Describe("Starting CatalogSource e2e tests", func() {
15851584
SourceType: v1alpha1.SourceTypeGrpc,
15861585
Image: "quay.io/olmtest/old-opm-catsrc:v1.21.0",
15871586
GrpcPodConfig: &v1alpha1.GrpcPodConfig{
1588-
SecurityContextConfig: operatorsv1alpha1.Legacy,
1587+
SecurityContextConfig: v1alpha1.Legacy,
15891588
},
15901589
},
15911590
}

Diff for: test/e2e/subscription_e2e_test.go

+25-22
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import (
3232

3333
"github.com/operator-framework/api/pkg/lib/version"
3434
operatorsv1 "github.com/operator-framework/api/pkg/operators/v1"
35-
"github.com/operator-framework/api/pkg/operators/v1alpha1"
3635
operatorsv1alpha1 "github.com/operator-framework/api/pkg/operators/v1alpha1"
3736
"github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned"
3837
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/install"
@@ -170,6 +169,7 @@ var _ = Describe("Subscription", func() {
170169

171170
By(fmt.Sprintf("creating a subscription: %s/%s", generatedNamespace.GetName(), testSubscriptionName))
172171
cleanup, _ := createSubscription(GinkgoT(), crc, generatedNamespace.GetName(), testSubscriptionName, testPackageName, betaChannel, operatorsv1alpha1.ApprovalAutomatic)
172+
173173
defer cleanup()
174174

175175
By("waiting for the subscription to have a current CSV and be at latest")
@@ -366,6 +366,7 @@ var _ = Describe("Subscription", func() {
366366

367367
By(`Set the InstallPlan's approved to True`)
368368
Eventually(Apply(newInstallPlan, func(p *operatorsv1alpha1.InstallPlan) error {
369+
369370
p.Spec.Approved = true
370371
return nil
371372
})).Should(Succeed())
@@ -1084,6 +1085,7 @@ var _ = Describe("Subscription", func() {
10841085
By(`Set the InstallPlan's approval mode to Manual`)
10851086
Eventually(Apply(plan, func(p *operatorsv1alpha1.InstallPlan) error {
10861087
p.Spec.Approval = operatorsv1alpha1.ApprovalManual
1088+
10871089
p.Spec.Approved = false
10881090
return nil
10891091
})).Should(Succeed())
@@ -2440,7 +2442,7 @@ var _ = Describe("Subscription", func() {
24402442
if err != nil {
24412443
return "", err
24422444
}
2443-
cond := fetched.Status.GetCondition(v1alpha1.SubscriptionBundleUnpacking)
2445+
cond := fetched.Status.GetCondition(operatorsv1alpha1.SubscriptionBundleUnpacking)
24442446
return cond.Status, nil
24452447
},
24462448
5*time.Minute,
@@ -2454,7 +2456,7 @@ var _ = Describe("Subscription", func() {
24542456
if err != nil {
24552457
return "", err
24562458
}
2457-
cond := fetched.Status.GetCondition(v1alpha1.SubscriptionBundleUnpackFailed)
2459+
cond := fetched.Status.GetCondition(operatorsv1alpha1.SubscriptionBundleUnpackFailed)
24582460
return cond.Status, nil
24592461
},
24602462
5*time.Minute,
@@ -2483,9 +2485,9 @@ var _ = Describe("Subscription", func() {
24832485
if err != nil {
24842486
return "", err
24852487
}
2486-
cond := fetched.Status.GetCondition(v1alpha1.SubscriptionBundleUnpackFailed)
2488+
cond := fetched.Status.GetCondition(operatorsv1alpha1.SubscriptionBundleUnpackFailed)
24872489
if cond.Status != corev1.ConditionTrue || cond.Reason != "BundleUnpackFailed" {
2488-
return "", fmt.Errorf("%s condition not found", v1alpha1.SubscriptionBundleUnpackFailed)
2490+
return "", fmt.Errorf("%s condition not found", operatorsv1alpha1.SubscriptionBundleUnpackFailed)
24892491
}
24902492

24912493
return cond.Message, nil
@@ -2527,7 +2529,7 @@ var _ = Describe("Subscription", func() {
25272529

25282530
By("waiting for the subscription to have v0.2.0 installed with a Bundle Deprecated condition")
25292531
sub, err := fetchSubscription(crc, generatedNamespace.GetName(), subName, subscriptionHasCondition(
2530-
v1alpha1.SubscriptionBundleDeprecated,
2532+
operatorsv1alpha1.SubscriptionBundleDeprecated,
25312533
corev1.ConditionTrue,
25322534
"",
25332535
"olm.bundle/example-operator.v0.2.0: bundle \"example-operator.v0.2.0\" has been deprecated. Please switch to a different one."))
@@ -2557,7 +2559,7 @@ var _ = Describe("Subscription", func() {
25572559
Expect(err).To(BeNil())
25582560

25592561
By("waiting for the subscription to have v0.3.0 installed with no deprecation message present")
2560-
_, err = fetchSubscription(crc, generatedNamespace.GetName(), subName, subscriptionDoesNotHaveCondition(v1alpha1.SubscriptionDeprecated))
2562+
_, err = fetchSubscription(crc, generatedNamespace.GetName(), subName, subscriptionDoesNotHaveCondition(operatorsv1alpha1.SubscriptionDeprecated))
25612563
Expect(err).Should(BeNil())
25622564
})
25632565

@@ -2574,7 +2576,7 @@ var _ = Describe("Subscription", func() {
25742576

25752577
By("waiting for the subscription to have v0.2.0 installed with a Bundle Deprecated condition")
25762578
sub, err := fetchSubscription(crc, generatedNamespace.GetName(), subName, subscriptionHasCondition(
2577-
v1alpha1.SubscriptionBundleDeprecated,
2579+
operatorsv1alpha1.SubscriptionBundleDeprecated,
25782580
corev1.ConditionTrue,
25792581
"",
25802582
"olm.bundle/example-operator.v0.2.0: bundle \"example-operator.v0.2.0\" has been deprecated. Please switch to a different one."))
@@ -2592,10 +2594,10 @@ var _ = Describe("Subscription", func() {
25922594
Expect(err).To(BeNil())
25932595

25942596
By("waiting for the subscription to have v0.3.0 installed with a Package deprecated condition")
2595-
_, err = fetchSubscription(crc, generatedNamespace.GetName(), subName, subscriptionDoesNotHaveCondition(v1alpha1.SubscriptionBundleDeprecated))
2597+
_, err = fetchSubscription(crc, generatedNamespace.GetName(), subName, subscriptionDoesNotHaveCondition(operatorsv1alpha1.SubscriptionBundleDeprecated))
25962598
Expect(err).Should(BeNil())
25972599
sub, err = fetchSubscription(crc, generatedNamespace.GetName(), subName, subscriptionHasCondition(
2598-
v1alpha1.SubscriptionPackageDeprecated,
2600+
operatorsv1alpha1.SubscriptionPackageDeprecated,
25992601
corev1.ConditionTrue,
26002602
"",
26012603
"olm.package/packageA: packageA has been deprecated. Please switch to packageB."))
@@ -2650,9 +2652,9 @@ var _ = Describe("Subscription", func() {
26502652
if err != nil {
26512653
return false, err
26522654
}
2653-
cond := sub.Status.GetCondition(v1alpha1.SubscriptionDeprecated)
2655+
cond := sub.Status.GetCondition(operatorsv1alpha1.SubscriptionDeprecated)
26542656
if cond.Status != corev1.ConditionTrue {
2655-
return false, fmt.Errorf("%s condition not found", v1alpha1.SubscriptionDeprecated)
2657+
return false, fmt.Errorf("%s condition not found", operatorsv1alpha1.SubscriptionDeprecated)
26562658
}
26572659

26582660
return true, nil
@@ -2774,8 +2776,8 @@ properties:
27742776
if err != nil {
27752777
return err
27762778
}
2777-
if cond := fetched.Status.GetCondition(v1alpha1.SubscriptionBundleUnpackFailed); cond.Status != corev1.ConditionTrue || cond.Reason != "BundleUnpackFailed" {
2778-
return fmt.Errorf("%s condition not found", v1alpha1.SubscriptionBundleUnpackFailed)
2779+
if cond := fetched.Status.GetCondition(operatorsv1alpha1.SubscriptionBundleUnpackFailed); cond.Status != corev1.ConditionTrue || cond.Reason != "BundleUnpackFailed" {
2780+
return fmt.Errorf("%s condition not found", operatorsv1alpha1.SubscriptionBundleUnpackFailed)
27792781
}
27802782
return nil
27812783
},
@@ -2806,11 +2808,11 @@ properties:
28062808
if err != nil {
28072809
return err
28082810
}
2809-
if cond := fetched.Status.GetCondition(v1alpha1.SubscriptionBundleUnpacking); cond.Status != corev1.ConditionUnknown {
2810-
return fmt.Errorf("subscription condition %s has unexpected value %s, expected %s", v1alpha1.SubscriptionBundleUnpacking, cond.Status, corev1.ConditionFalse)
2811+
if cond := fetched.Status.GetCondition(operatorsv1alpha1.SubscriptionBundleUnpacking); cond.Status != corev1.ConditionUnknown {
2812+
return fmt.Errorf("subscription condition %s has unexpected value %s, expected %s", operatorsv1alpha1.SubscriptionBundleUnpacking, cond.Status, corev1.ConditionFalse)
28112813
}
2812-
if cond := fetched.Status.GetCondition(v1alpha1.SubscriptionBundleUnpackFailed); cond.Status != corev1.ConditionUnknown {
2813-
return fmt.Errorf("unexpected condition %s on subscription", v1alpha1.SubscriptionBundleUnpackFailed)
2814+
if cond := fetched.Status.GetCondition(operatorsv1alpha1.SubscriptionBundleUnpackFailed); cond.Status != corev1.ConditionUnknown {
2815+
return fmt.Errorf("unexpected condition %s on subscription", operatorsv1alpha1.SubscriptionBundleUnpackFailed)
28142816
}
28152817
return nil
28162818
}).Should(Succeed())
@@ -2846,11 +2848,11 @@ properties:
28462848
if err != nil {
28472849
return err
28482850
}
2849-
if cond := fetched.Status.GetCondition(v1alpha1.SubscriptionBundleUnpacking); cond.Status == corev1.ConditionTrue {
2850-
return fmt.Errorf("unexpected condition status for %s on subscription %s", v1alpha1.SubscriptionBundleUnpacking, subName)
2851+
if cond := fetched.Status.GetCondition(operatorsv1alpha1.SubscriptionBundleUnpacking); cond.Status == corev1.ConditionTrue {
2852+
return fmt.Errorf("unexpected condition status for %s on subscription %s", operatorsv1alpha1.SubscriptionBundleUnpacking, subName)
28512853
}
2852-
if cond := fetched.Status.GetCondition(v1alpha1.SubscriptionBundleUnpackFailed); cond.Status == corev1.ConditionTrue {
2853-
return fmt.Errorf("unexpected condition status for %s on subscription %s", v1alpha1.SubscriptionBundleUnpackFailed, subName)
2854+
if cond := fetched.Status.GetCondition(operatorsv1alpha1.SubscriptionBundleUnpackFailed); cond.Status == corev1.ConditionTrue {
2855+
return fmt.Errorf("unexpected condition status for %s on subscription %s", operatorsv1alpha1.SubscriptionBundleUnpackFailed, subName)
28542856
}
28552857
return nil
28562858
}).Should(Succeed())
@@ -3396,6 +3398,7 @@ func waitForSubscriptionToDelete(namespace, name string, c versioned.Interface)
33963398
}
33973399

33983400
func checkDeploymentHasPodConfigNodeSelector(t GinkgoTInterface, client operatorclient.ClientInterface, csv *operatorsv1alpha1.ClusterServiceVersion, nodeSelector map[string]string) error {
3401+
33993402
resolver := install.StrategyResolver{}
34003403

34013404
strategy, err := resolver.UnmarshalStrategy(csv.Spec.InstallStrategy)

0 commit comments

Comments
 (0)