aboutsummaryrefslogtreecommitdiffstats
path: root/config-model-api/src/main/java/com/yahoo
diff options
context:
space:
mode:
authorJon Marius Venstad <venstad@gmail.com>2020-11-20 12:42:47 +0100
committerJon Marius Venstad <venstad@gmail.com>2020-11-20 12:42:47 +0100
commit28ebee04d75871c2e268bfd8375b02759ca52d4e (patch)
tree7216fd3c40cb21cd8cd965459b594ba13a6ead7e /config-model-api/src/main/java/com/yahoo
parentb7835ceb503084f32cb09875b1e6243bed81e463 (diff)
Add Optional<ValidationId> to ConfigActionChange and use to validate actions
Diffstat (limited to 'config-model-api/src/main/java/com/yahoo')
-rw-r--r--config-model-api/src/main/java/com/yahoo/config/model/api/ConfigChangeAction.java10
-rw-r--r--config-model-api/src/main/java/com/yahoo/config/model/api/ConfigChangeRefeedAction.java4
-rw-r--r--config-model-api/src/main/java/com/yahoo/config/model/api/ConfigChangeReindexAction.java4
-rw-r--r--config-model-api/src/main/java/com/yahoo/config/model/api/DisallowableConfigChangeAction.java16
4 files changed, 10 insertions, 24 deletions
diff --git a/config-model-api/src/main/java/com/yahoo/config/model/api/ConfigChangeAction.java b/config-model-api/src/main/java/com/yahoo/config/model/api/ConfigChangeAction.java
index f8f0a3dfb1a..70a54918216 100644
--- a/config-model-api/src/main/java/com/yahoo/config/model/api/ConfigChangeAction.java
+++ b/config-model-api/src/main/java/com/yahoo/config/model/api/ConfigChangeAction.java
@@ -5,6 +5,7 @@ import com.yahoo.config.application.api.ValidationId;
import com.yahoo.config.provision.ClusterSpec;
import java.util.List;
+import java.util.Optional;
/**
* Contains the action to be performed on the given services to handle a config change
@@ -38,12 +39,13 @@ public interface ConfigChangeAction {
/** Returns the list of services where the action must be performed */
List<ServiceInfo> getServices();
- /**
- * Returns whether this change should be allowed.
- * Implementations which allow this to return false should inherit {@link DisallowableConfigChangeAction}
- */
+ /** Returns whether this change should be allowed. */
+ // TODO jonmv: remove in 2021.
boolean allowed();
+ /** When this is non-empty, validation may fail unless this validation id is allowed by validation overrides. */
+ default Optional<ValidationId> validationId() { return Optional.empty(); }
+
/** The id of the cluster that needs this action applied */
// TODO: Remove this default implementation after October 2020
default ClusterSpec.Id clusterId() { return null; }
diff --git a/config-model-api/src/main/java/com/yahoo/config/model/api/ConfigChangeRefeedAction.java b/config-model-api/src/main/java/com/yahoo/config/model/api/ConfigChangeRefeedAction.java
index 3d7d0336da0..13109088dcd 100644
--- a/config-model-api/src/main/java/com/yahoo/config/model/api/ConfigChangeRefeedAction.java
+++ b/config-model-api/src/main/java/com/yahoo/config/model/api/ConfigChangeRefeedAction.java
@@ -8,13 +8,13 @@ import com.yahoo.config.application.api.ValidationId;
*
* @author geirst
*/
-public interface ConfigChangeRefeedAction extends DisallowableConfigChangeAction {
+public interface ConfigChangeRefeedAction extends ConfigChangeAction {
@Override
default Type getType() { return Type.REFEED; }
/** Returns the name identifying this kind of change, used to identify names which should be allowed */
- default String name() { return validationId().value(); }
+ default String name() { return validationId().orElseThrow().value(); }
/** Returns the name of the document type that one must re-feed to handle this config change */
String getDocumentType();
diff --git a/config-model-api/src/main/java/com/yahoo/config/model/api/ConfigChangeReindexAction.java b/config-model-api/src/main/java/com/yahoo/config/model/api/ConfigChangeReindexAction.java
index 52174f0eba2..bb714a55f94 100644
--- a/config-model-api/src/main/java/com/yahoo/config/model/api/ConfigChangeReindexAction.java
+++ b/config-model-api/src/main/java/com/yahoo/config/model/api/ConfigChangeReindexAction.java
@@ -8,12 +8,12 @@ import com.yahoo.config.application.api.ValidationId;
*
* @author bjorncs
*/
-public interface ConfigChangeReindexAction extends DisallowableConfigChangeAction {
+public interface ConfigChangeReindexAction extends ConfigChangeAction {
@Override default Type getType() { return Type.REINDEX; }
/** @return name identifying this kind of change, used to identify names which should be allowed */
- default String name() { return validationId().value(); }
+ default String name() { return validationId().orElseThrow().value(); }
/** @return name of the document type that must be re-indexed */
String getDocumentType();
diff --git a/config-model-api/src/main/java/com/yahoo/config/model/api/DisallowableConfigChangeAction.java b/config-model-api/src/main/java/com/yahoo/config/model/api/DisallowableConfigChangeAction.java
deleted file mode 100644
index a6308b22e3b..00000000000
--- a/config-model-api/src/main/java/com/yahoo/config/model/api/DisallowableConfigChangeAction.java
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.config.model.api;
-
-import com.yahoo.config.application.api.ValidationId;
-
-/**
- * Sub-interface for {@link ConfigChangeAction} children that may be disallowed.
- *
- * @author jonmv
- */
-public interface DisallowableConfigChangeAction extends ConfigChangeAction {
-
- /** Returns the validation ID used to allow deployment when this action is required. */
- ValidationId validationId();
-
-}