Skip to content

Commit

Permalink
Merge pull request #220 from ashishmax31/naming-changes-for-olm-objs
Browse files Browse the repository at this point in the history
catalogsource object and subscription object name change
  • Loading branch information
openshift-ci[bot] authored Jun 20, 2022
2 parents 67aa7d5 + 0ae3965 commit f495c08
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 15 deletions.
15 changes: 8 additions & 7 deletions integration/addon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (

addonsv1alpha1 "github.com/openshift/addon-operator/apis/addons/v1alpha1"
"github.com/openshift/addon-operator/integration"
addonUtil "github.com/openshift/addon-operator/internal/controllers/addon"
)

func (s *integrationTestSuite) TestAddon() {
Expand Down Expand Up @@ -119,7 +120,7 @@ func (s *integrationTestSuite) TestAddon() {
s.Run("catalogsource exists", func() {
currentCatalogSource := &operatorsv1alpha1.CatalogSource{}
err := integration.Client.Get(ctx, client.ObjectKey{
Name: addon.Name,
Name: addonUtil.CatalogSourceName(addon),
Namespace: addon.Spec.Install.OLMOwnNamespace.Namespace,
}, currentCatalogSource)
s.Assert().NoError(err, "could not get CatalogSource %s", addon.Name)
Expand All @@ -133,7 +134,7 @@ func (s *integrationTestSuite) TestAddon() {
{
err := integration.Client.Get(ctx, client.ObjectKey{
Namespace: addon.Spec.Install.OLMOwnNamespace.Namespace,
Name: addon.Name,
Name: addonUtil.SubscriptionName(addon),
}, subscription)
s.Require().NoError(err)

Expand Down Expand Up @@ -164,7 +165,7 @@ func (s *integrationTestSuite) TestAddon() {

err := integration.Client.Get(ctx, client.ObjectKey{
Namespace: addon.Spec.Install.OLMOwnNamespace.Namespace,
Name: addon.Name,
Name: addonUtil.SubscriptionName(addon),
}, subscription)
s.Require().NoError(err)
envObjectsPresent := subscription.Spec.Config.Env
Expand All @@ -187,7 +188,7 @@ func (s *integrationTestSuite) TestAddon() {
// assert that CatalogSource is gone
currentCatalogSource := &operatorsv1alpha1.CatalogSource{}
err = integration.Client.Get(ctx, client.ObjectKey{
Name: addon.Name,
Name: addonUtil.CatalogSourceName(addon),
Namespace: addon.Spec.Install.OLMOwnNamespace.Namespace,
}, currentCatalogSource)
s.Assert().True(k8sApiErrors.IsNotFound(err), "CatalogSource not deleted: %s", currentCatalogSource.Name)
Expand Down Expand Up @@ -232,9 +233,9 @@ func (s *integrationTestSuite) TestAddonWithAdditionalCatalogSrc() {
s.Assert().NoError(err, "could not get CatalogSource %s", addon.Name)
s.Assert().Equal(3, len(catalogSourceList.Items))
expectedImages := map[string]string{
"test-1": referenceAddonCatalogSourceImageWorking,
"test-2": referenceAddonCatalogSourceImageWorking,
addon.Name: referenceAddonCatalogSourceImageWorking,
"test-1": referenceAddonCatalogSourceImageWorking,
"test-2": referenceAddonCatalogSourceImageWorking,
addonUtil.CatalogSourceName(addon): referenceAddonCatalogSourceImageWorking,
}
for _, ctlgSrc := range catalogSourceList.Items {
s.Assert().Equal(expectedImages[ctlgSrc.Name], ctlgSrc.Spec.Image)
Expand Down
5 changes: 3 additions & 2 deletions integration/broken_subscription_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (

addonsv1alpha1 "github.com/openshift/addon-operator/apis/addons/v1alpha1"
"github.com/openshift/addon-operator/integration"
addonUtil "github.com/openshift/addon-operator/internal/controllers/addon"
)

// This test deploys a version of our addon where InstallPlan and
Expand Down Expand Up @@ -55,7 +56,7 @@ func (s *integrationTestSuite) TestAddon_BrokenSubscription() {
subscription := &operatorsv1alpha1.Subscription{}
err := integration.Client.Get(ctx, client.ObjectKey{
Namespace: addon.Spec.Install.OLMOwnNamespace.Namespace,
Name: addon.Name,
Name: addonUtil.SubscriptionName(addon),
}, subscription)
s.Require().NoError(err)

Expand All @@ -73,7 +74,7 @@ func (s *integrationTestSuite) TestAddon_BrokenSubscription() {
// assert that CatalogSource is gone
currentCatalogSource := &operatorsv1alpha1.CatalogSource{}
err = integration.Client.Get(ctx, types.NamespacedName{
Name: addon.Name,
Name: addonUtil.CatalogSourceName(addon),
Namespace: addon.Spec.Install.OLMOwnNamespace.Namespace,
}, currentCatalogSource)
s.Assert().True(k8sApiErrors.IsNotFound(err), "CatalogSource not deleted: %s", currentCatalogSource.Name)
Expand Down
4 changes: 2 additions & 2 deletions integration/fixtures_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ func namespace_TestResourceAdoption() *corev1.Namespace {
func catalogsource_TestResourceAdoption() *operatorsv1alpha1.CatalogSource {
return &operatorsv1alpha1.CatalogSource{
ObjectMeta: metav1.ObjectMeta{
Name: referenceAddonName,
Name: fmt.Sprintf("addon-%s-catalog", referenceAddonName),
Namespace: referenceAddonNamespace,
},
Spec: operatorsv1alpha1.CatalogSourceSpec{
Expand All @@ -247,7 +247,7 @@ func operatorgroup_TestResourceAdoption() *operatorsv1.OperatorGroup {
func subscription_TestResourceAdoption() *operatorsv1alpha1.Subscription {
return &operatorsv1alpha1.Subscription{
ObjectMeta: metav1.ObjectMeta{
Name: referenceAddonName,
Name: fmt.Sprintf("addon-%s", referenceAddonName),
Namespace: referenceAddonNamespace},
Spec: &operatorsv1alpha1.SubscriptionSpec{
CatalogSource: referenceAddonName,
Expand Down
5 changes: 3 additions & 2 deletions integration/resource_adoption_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
addonsv1alpha1 "github.com/openshift/addon-operator/apis/addons/v1alpha1"
"github.com/openshift/addon-operator/integration"
"github.com/openshift/addon-operator/internal/controllers"
addonUtil "github.com/openshift/addon-operator/internal/controllers/addon"
)

func (s *integrationTestSuite) TestResourceAdoption() {
Expand Down Expand Up @@ -107,7 +108,7 @@ func (s *integrationTestSuite) TestResourceAdoption() {
{
observedSubscription := &operatorsv1alpha1.Subscription{
ObjectMeta: metav1.ObjectMeta{
Name: referenceAddonName,
Name: addonUtil.SubscriptionName(addon),
Namespace: referenceAddonNamespace,
},
}
Expand Down Expand Up @@ -142,7 +143,7 @@ func (s *integrationTestSuite) TestResourceAdoption() {
{
observedCS := &operatorsv1alpha1.CatalogSource{
ObjectMeta: metav1.ObjectMeta{
Name: referenceAddonName,
Name: addonUtil.CatalogSourceName(addon),
Namespace: referenceAddonNamespace,
},
}
Expand Down
2 changes: 1 addition & 1 deletion internal/controllers/addon/phase_ensure_catalogsource.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (r *olmReconciler) ensureCatalogSource(

catalogSource := &operatorsv1alpha1.CatalogSource{
ObjectMeta: metav1.ObjectMeta{
Name: addon.Name,
Name: CatalogSourceName(addon),
Namespace: commonConfig.Namespace,
},
Spec: operatorsv1alpha1.CatalogSourceSpec{
Expand Down
2 changes: 1 addition & 1 deletion internal/controllers/addon/phase_ensure_subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (r *olmReconciler) ensureSubscription(
subscriptionConfigObject := createSubscriptionConfigObject(commonInstallOptions)
desiredSubscription := &operatorsv1alpha1.Subscription{
ObjectMeta: metav1.ObjectMeta{
Name: addon.Name,
Name: SubscriptionName(addon),
Namespace: commonInstallOptions.Namespace,
},
Spec: &operatorsv1alpha1.SubscriptionSpec{
Expand Down
8 changes: 8 additions & 0 deletions internal/controllers/addon/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,5 +342,13 @@ func getCatalogSourceNetworkPolicyName(addon *addonsv1alpha1.Addon) string {
return fmt.Sprintf("addon-%s-catalogs", addon.Name)
}

func CatalogSourceName(addon *addonsv1alpha1.Addon) string {
return fmt.Sprintf("addon-%s-catalog", addon.Name)
}

func SubscriptionName(addon *addonsv1alpha1.Addon) string {
return fmt.Sprintf("addon-%s", addon.Name)
}

func corev1ProtocolPtr(proto corev1.Protocol) *corev1.Protocol { return &proto }
func intOrStringPtr(iors intstr.IntOrString) *intstr.IntOrString { return &iors }

0 comments on commit f495c08

Please sign in to comment.