|
9 | 9 |
|
10 | 10 | "github.com/openmeterio/openmeter/api" |
11 | 11 | "github.com/openmeterio/openmeter/openmeter/productcatalog" |
| 12 | + "github.com/openmeterio/openmeter/openmeter/productcatalog/addon" |
12 | 13 | "github.com/openmeterio/openmeter/openmeter/subscription" |
13 | 14 | subscriptionaddon "github.com/openmeterio/openmeter/openmeter/subscription/addon" |
14 | 15 | subscriptionworkflow "github.com/openmeterio/openmeter/openmeter/subscription/workflow" |
@@ -59,12 +60,20 @@ func (h *handler) CreateSubscriptionAddon() CreateSubscriptionAddonHandler { |
59 | 60 | func(ctx context.Context, req CreateSubscriptionAddonRequest) (CreateSubscriptionAddonResponse, error) { |
60 | 61 | var def CreateSubscriptionAddonResponse |
61 | 62 |
|
62 | | - currentView, err := h.SubscriptionService.GetView(ctx, req.SubscriptionID) |
| 63 | + // The add-on's own rate cards are serialized in the response, so reject a unit_config |
| 64 | + // add-on (the v1 shape cannot represent it) before it lands on the subscription. We do |
| 65 | + // NOT reject based on the subscription's plan |
| 66 | + addonToAdd, err := h.AddonService.GetAddon(ctx, addon.GetAddonInput{ |
| 67 | + NamespacedID: models.NamespacedID{ |
| 68 | + Namespace: req.SubscriptionID.Namespace, |
| 69 | + ID: req.AddonInput.AddonID, |
| 70 | + }, |
| 71 | + }) |
63 | 72 | if err != nil { |
64 | 73 | return def, err |
65 | 74 | } |
66 | 75 |
|
67 | | - if currentView.Spec.HasUnitConfig() { |
| 76 | + if addonToAdd.AsProductCatalogAddon().HasUnitConfig() { |
68 | 77 | return def, productcatalog.ErrUnitConfigNotRepresentable |
69 | 78 | } |
70 | 79 |
|
|
0 commit comments