From 82a7e5c492cef0ebefaf54b9bdf95eb531bbad44 Mon Sep 17 00:00:00 2001 From: Martin Polden Date: Mon, 4 Sep 2023 12:36:50 +0200 Subject: Add auth method to ApplicationClusterEndpoint --- .../model/api/ApplicationClusterEndpoint.java | 61 ++++++++++++++-------- .../yahoo/config/model/api/ContainerEndpoint.java | 23 +++++--- 2 files changed, 55 insertions(+), 29 deletions(-) (limited to 'config-model-api/src') diff --git a/config-model-api/src/main/java/com/yahoo/config/model/api/ApplicationClusterEndpoint.java b/config-model-api/src/main/java/com/yahoo/config/model/api/ApplicationClusterEndpoint.java index b7969267328..e70b0f1a599 100644 --- a/config-model-api/src/main/java/com/yahoo/config/model/api/ApplicationClusterEndpoint.java +++ b/config-model-api/src/main/java/com/yahoo/config/model/api/ApplicationClusterEndpoint.java @@ -18,21 +18,6 @@ import java.util.stream.Stream; * @author mortent */ public class ApplicationClusterEndpoint { - @Override - public String toString() { - return "ApplicationClusterEndpoint{" + - "dnsName=" + dnsName + - ", scope=" + scope + - ", routingMethod=" + routingMethod + - ", weight=" + weight + - ", hostNames=" + hostNames + - ", clusterId='" + clusterId + "'" + - '}'; - } - - public enum Scope {application, global, zone} - - public enum RoutingMethod {shared, sharedLayer4, exclusive} private final DnsName dnsName; private final Scope scope; @@ -40,14 +25,16 @@ public class ApplicationClusterEndpoint { private final int weight; private final List hostNames; private final String clusterId; + private final AuthMethod authMethod; - private ApplicationClusterEndpoint(DnsName dnsName, Scope scope, RoutingMethod routingMethod, int weight, List hostNames, String clusterId) { - this.dnsName = dnsName; - this.scope = scope; - this.routingMethod = routingMethod; + private ApplicationClusterEndpoint(DnsName dnsName, Scope scope, RoutingMethod routingMethod, int weight, List hostNames, String clusterId, AuthMethod authMethod) { + this.dnsName = Objects.requireNonNull(dnsName); + this.scope = Objects.requireNonNull(scope); + this.routingMethod = Objects.requireNonNull(routingMethod); this.weight = weight; - this.hostNames = List.copyOf(hostNames); - this.clusterId = clusterId; + this.hostNames = List.copyOf(Objects.requireNonNull(hostNames)); + this.clusterId = Objects.requireNonNull(clusterId); + this.authMethod = Objects.requireNonNull(authMethod); } public DnsName dnsName() { @@ -74,10 +61,33 @@ public class ApplicationClusterEndpoint { return clusterId; } + public AuthMethod authMethod() { + return authMethod; + } + + @Override + public String toString() { + return "ApplicationClusterEndpoint{" + + "dnsName=" + dnsName + + ", scope=" + scope + + ", routingMethod=" + routingMethod + + ", weight=" + weight + + ", hostNames=" + hostNames + + ", clusterId='" + clusterId + '\'' + + ", authMethod=" + authMethod + + '}'; + } + public static Builder builder() { return new Builder(); } + public enum Scope { application, global, zone } + + public enum RoutingMethod { shared, sharedLayer4, exclusive } + + public enum AuthMethod { mtls, token } + public static class Builder { private DnsName dnsName; @@ -86,6 +96,7 @@ public class ApplicationClusterEndpoint { private int weigth = 1; private List hosts; private String clusterId; + private AuthMethod authMethod; public Builder dnsName(DnsName name) { this.dnsName = name; @@ -132,9 +143,15 @@ public class ApplicationClusterEndpoint { return this; } + public Builder authMethod(AuthMethod authMethod) { + this.authMethod = authMethod; + return this; + } + public ApplicationClusterEndpoint build() { - return new ApplicationClusterEndpoint(dnsName, scope, routingMethod, weigth, hosts, clusterId); + return new ApplicationClusterEndpoint(dnsName, scope, routingMethod, weigth, hosts, clusterId, authMethod); } + } public static class DnsName implements Comparable { diff --git a/config-model-api/src/main/java/com/yahoo/config/model/api/ContainerEndpoint.java b/config-model-api/src/main/java/com/yahoo/config/model/api/ContainerEndpoint.java index 78da750fb5b..de06ddd549a 100644 --- a/config-model-api/src/main/java/com/yahoo/config/model/api/ContainerEndpoint.java +++ b/config-model-api/src/main/java/com/yahoo/config/model/api/ContainerEndpoint.java @@ -3,9 +3,7 @@ package com.yahoo.config.model.api; import java.util.List; import java.util.Objects; -import java.util.Optional; import java.util.OptionalInt; -import java.util.OptionalLong; /** * ContainerEndpoint tracks the service names that a Container Cluster should be @@ -21,6 +19,7 @@ public class ContainerEndpoint { private final List names; private final OptionalInt weight; private final ApplicationClusterEndpoint.RoutingMethod routingMethod; + private final ApplicationClusterEndpoint.AuthMethod authMethod; public ContainerEndpoint(String clusterId, ApplicationClusterEndpoint.Scope scope, List names) { this(clusterId, scope, names, OptionalInt.empty()); @@ -31,11 +30,16 @@ public class ContainerEndpoint { } public ContainerEndpoint(String clusterId, ApplicationClusterEndpoint.Scope scope, List names, OptionalInt weight, ApplicationClusterEndpoint.RoutingMethod routingMethod) { + this(clusterId, scope, names, weight, routingMethod, ApplicationClusterEndpoint.AuthMethod.mtls); + } + + public ContainerEndpoint(String clusterId, ApplicationClusterEndpoint.Scope scope, List names, OptionalInt weight, ApplicationClusterEndpoint.RoutingMethod routingMethod, ApplicationClusterEndpoint.AuthMethod authMethod) { this.clusterId = Objects.requireNonNull(clusterId); this.scope = Objects.requireNonNull(scope); this.names = List.copyOf(Objects.requireNonNull(names)); - this.weight = weight; - this.routingMethod = routingMethod; + this.weight = Objects.requireNonNull(weight); + this.routingMethod = Objects.requireNonNull(routingMethod); + this.authMethod = Objects.requireNonNull(authMethod); } public String clusterId() { @@ -58,6 +62,10 @@ public class ContainerEndpoint { return routingMethod; } + public ApplicationClusterEndpoint.AuthMethod authMethod() { + return authMethod; + } + @Override public boolean equals(Object o) { if (this == o) return true; @@ -67,16 +75,17 @@ public class ContainerEndpoint { Objects.equals(scope, that.scope) && Objects.equals(names, that.names) && Objects.equals(weight, that.weight) && - Objects.equals(routingMethod, that.routingMethod); + Objects.equals(routingMethod, that.routingMethod) && + Objects.equals(authMethod, that.authMethod); } @Override public int hashCode() { - return Objects.hash(clusterId, names, scope, weight, routingMethod); + return Objects.hash(clusterId, names, scope, weight, routingMethod, authMethod); } @Override public String toString() { - return String.format("container endpoint %s -> %s [scope=%s, weight=%s, routingMetod=%s]", clusterId, names, scope, weight, routingMethod); + return String.format("container endpoint %s -> %s [scope=%s, weight=%s, routingMethod=%s, authMethod=%s]", clusterId, names, scope, weight, routingMethod, authMethod); } } -- cgit v1.2.3