From 30dd6c13e1d0c65b9089946410feb1234a6843b9 Mon Sep 17 00:00:00 2001 From: kamaleshnneerasa Date: Fri, 5 Nov 2021 11:52:51 +0530 Subject: [PATCH 1/2] Adding enabled,description fields in label app rules --- .../rule/config/service/v1/label_application_rule.proto | 2 ++ .../rule/config/service/LabelApplicationRuleValidatorImpl.java | 2 ++ .../service/LabelApplicationRuleConfigServiceImplTest.java | 2 ++ .../rule/config/service/LabelApplicationRuleValidatorTest.java | 3 +++ 4 files changed, 9 insertions(+) diff --git a/label-application-rule-config-service-api/src/main/proto/org/hypertrace/label/application/rule/config/service/v1/label_application_rule.proto b/label-application-rule-config-service-api/src/main/proto/org/hypertrace/label/application/rule/config/service/v1/label_application_rule.proto index 240c6986..11760da4 100644 --- a/label-application-rule-config-service-api/src/main/proto/org/hypertrace/label/application/rule/config/service/v1/label_application_rule.proto +++ b/label-application-rule-config-service-api/src/main/proto/org/hypertrace/label/application/rule/config/service/v1/label_application_rule.proto @@ -13,6 +13,8 @@ message LabelApplicationRuleData { string name = 1; Condition matching_condition = 2; Action label_action = 3; + bool enabled = 4; + optional string description = 5; message Condition { oneof condition { diff --git a/label-application-rule-config-service-impl/src/main/java/org/hypertrace/label/application/rule/config/service/LabelApplicationRuleValidatorImpl.java b/label-application-rule-config-service-impl/src/main/java/org/hypertrace/label/application/rule/config/service/LabelApplicationRuleValidatorImpl.java index fcd21b53..c86774f3 100644 --- a/label-application-rule-config-service-impl/src/main/java/org/hypertrace/label/application/rule/config/service/LabelApplicationRuleValidatorImpl.java +++ b/label-application-rule-config-service-impl/src/main/java/org/hypertrace/label/application/rule/config/service/LabelApplicationRuleValidatorImpl.java @@ -60,6 +60,8 @@ private void validateLabelApplicationRuleData(LabelApplicationRuleData labelAppl labelApplicationRuleData, labelApplicationRuleData.NAME_FIELD_NUMBER); validateCondition(labelApplicationRuleData.getMatchingCondition()); validateAction(labelApplicationRuleData.getLabelAction()); + validateNonDefaultPresenceOrThrow( + labelApplicationRuleData, labelApplicationRuleData.ENABLED_FIELD_NUMBER); } private void validateCondition(LabelApplicationRuleData.Condition condition) { diff --git a/label-application-rule-config-service-impl/src/test/java/org/hypertrace/label/application/rule/config/service/LabelApplicationRuleConfigServiceImplTest.java b/label-application-rule-config-service-impl/src/test/java/org/hypertrace/label/application/rule/config/service/LabelApplicationRuleConfigServiceImplTest.java index 41187ad7..fb2dd2a3 100644 --- a/label-application-rule-config-service-impl/src/test/java/org/hypertrace/label/application/rule/config/service/LabelApplicationRuleConfigServiceImplTest.java +++ b/label-application-rule-config-service-impl/src/test/java/org/hypertrace/label/application/rule/config/service/LabelApplicationRuleConfigServiceImplTest.java @@ -211,6 +211,7 @@ private LabelApplicationRuleData buildCompositeRuleData() { .setName("Composite rule") .setMatchingCondition(matchingCondition) .setLabelAction(buildAction()) + .setEnabled(true) .build(); } @@ -235,6 +236,7 @@ private LabelApplicationRuleData buildSimpleRuleData(String key, String value) { .setName("Simple rule") .setMatchingCondition(matchingCondition) .setLabelAction(buildAction()) + .setEnabled(true) .build(); } diff --git a/label-application-rule-config-service-impl/src/test/java/org/hypertrace/label/application/rule/config/service/LabelApplicationRuleValidatorTest.java b/label-application-rule-config-service-impl/src/test/java/org/hypertrace/label/application/rule/config/service/LabelApplicationRuleValidatorTest.java index ff5cec0c..20888ebd 100644 --- a/label-application-rule-config-service-impl/src/test/java/org/hypertrace/label/application/rule/config/service/LabelApplicationRuleValidatorTest.java +++ b/label-application-rule-config-service-impl/src/test/java/org/hypertrace/label/application/rule/config/service/LabelApplicationRuleValidatorTest.java @@ -222,6 +222,7 @@ private CreateLabelApplicationRuleRequest buildCreateCreateLabelApplicationRuleR .setName(name) .setMatchingCondition(matchingCondition) .setLabelAction(buildDynamicLabelAction(labelExpression.get())) + .setEnabled(true) .build(); } else { data = @@ -229,6 +230,7 @@ private CreateLabelApplicationRuleRequest buildCreateCreateLabelApplicationRuleR .setName(name) .setMatchingCondition(matchingCondition) .setLabelAction(buildAction()) + .setEnabled(true) .build(); } return CreateLabelApplicationRuleRequest.newBuilder().setData(data).build(); @@ -240,6 +242,7 @@ private CreateLabelApplicationRuleRequest buildCreateLabelApplicationRuleRequest LabelApplicationRuleData.newBuilder() .setName(name) .setMatchingCondition(matchingCondition) + .setEnabled(true) .build(); return CreateLabelApplicationRuleRequest.newBuilder().setData(data).build(); } From 51bd0530bb24eaa3015a39f5e97cde472dba4146 Mon Sep 17 00:00:00 2001 From: kamaleshnneerasa Date: Mon, 15 Nov 2021 12:26:13 +0530 Subject: [PATCH 2/2] Fixing resource name and namespace --- .../rule/config/service/LabelApplicationRuleStore.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/label-application-rule-config-service-impl/src/main/java/org/hypertrace/label/application/rule/config/service/LabelApplicationRuleStore.java b/label-application-rule-config-service-impl/src/main/java/org/hypertrace/label/application/rule/config/service/LabelApplicationRuleStore.java index 7b787c9a..0e44a8f1 100644 --- a/label-application-rule-config-service-impl/src/main/java/org/hypertrace/label/application/rule/config/service/LabelApplicationRuleStore.java +++ b/label-application-rule-config-service-impl/src/main/java/org/hypertrace/label/application/rule/config/service/LabelApplicationRuleStore.java @@ -10,9 +10,9 @@ import org.hypertrace.label.application.rule.config.service.v1.LabelApplicationRule; public class LabelApplicationRuleStore extends IdentifiedObjectStore { - private static final String LABEL_APPLICATION_RULE_CONFIG_RESOURCE_NAME = "label-config"; - private static final String LABEL_APPLICATION_RULE_CONFIG_RESOURCE_NAMESPACE = - "label-application-rules"; + private static final String LABEL_APPLICATION_RULE_CONFIG_RESOURCE_NAME = + "label-application-rule-config"; + private static final String LABEL_APPLICATION_RULE_CONFIG_RESOURCE_NAMESPACE = "labels"; LabelApplicationRuleStore( ConfigServiceGrpc.ConfigServiceBlockingStub stub,