Skip to content

Commit

Permalink
Update enforcer logic to match with latest application and subscripti…
Browse files Browse the repository at this point in the history
…on related changes
  • Loading branch information
ashera96 committed Oct 6, 2023
1 parent f6825c7 commit 674cc6f
Show file tree
Hide file tree
Showing 23 changed files with 2,029 additions and 475 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ message Subscription {
string subStatus = 2;
string uuid = 3;
string organization = 4;
API api = 5;
SubscribedAPI subscribedApi = 5;
string timeStamp = 6;
}

message API {
message SubscribedAPI {
string name = 1;
repeated string versions = 2;
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ spec:
subscriptionStatus: ACTIVE
organization: carbon.super
api:
name: PizzaShackAPI
name: AppSubTestAPI
versions:
- ^v1$
- ^1.*
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,17 @@ func sendSubUpdates(subscriptionsList *cpv1alpha2.SubscriptionList) {
func marshalSubscriptionList(subscriptionList []cpv1alpha2.Subscription) *subscription.SubscriptionList {
subscriptions := []*subscription.Subscription{}
for _, subInternal := range subscriptionList {
api := &subscription.API{}
subscribedApi := &subscription.SubscribedAPI{}
sub := &subscription.Subscription{
Uuid: string(subInternal.UID),
SubStatus: subInternal.Spec.SubscriptionStatus,
Organization: subInternal.Spec.Organization,
}
if subInternal.Spec.API.Name != "" && len(subInternal.Spec.API.Versions) > 0 {
api.Name = subInternal.Spec.API.Name
api.Versions = subInternal.Spec.API.Versions
subscribedApi.Name = subInternal.Spec.API.Name
subscribedApi.Versions = subInternal.Spec.API.Versions
}
sub.Api = api
sub.SubscribedApi = subscribedApi
subscriptions = append(subscriptions, sub)
}
return &subscription.SubscriptionList{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public static SubscriptionInfo toSubscriptionInfo(Subscription subscription,
subscriptionInfo.setAppUUID(subscription.getAppUUID());
subscriptionInfo.setPolicyId(subscription.getPolicyId());
subscriptionInfo.setSubscriptionId(subscription.getSubscriptionId());
subscriptionInfo.setSubscriptionState(subscription.getSubscriptionState());
subscriptionInfo.setSubscriptionState(subscription.getSubscriptionStatus());
return subscriptionInfo;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ public void onNext(DiscoveryResponse response) {
for (Any res : response.getResourcesList()) {
applicationMappingList.addAll(res.unpack(ApplicationMappingList.class).getListList());
}
// subscriptionDataStore.addApplicationMappings(applicationMappingList);
logger.info("Number of application key mappings received : " + applicationMappingList.size());
subscriptionDataStore.addApplicationMappings(applicationMappingList);
logger.info("Number of application mappings received : " + applicationMappingList.size());
ack();
} catch (Exception e) {
// catching generic error here to wrap any grpc communication errors in the runtime
Expand Down
Loading

0 comments on commit 674cc6f

Please sign in to comment.