|
|
|
@ -24,6 +24,7 @@ |
|
|
|
|
|
|
|
|
|
#include "absl/status/status.h" |
|
|
|
|
#include "absl/status/statusor.h" |
|
|
|
|
#include "absl/strings/match.h" |
|
|
|
|
#include "absl/strings/str_cat.h" |
|
|
|
|
#include "absl/strings/str_join.h" |
|
|
|
|
#include "absl/strings/strip.h" |
|
|
|
@ -187,23 +188,32 @@ XdsClusterResource::Eds EdsConfigParse( |
|
|
|
|
if (eds_cluster_config == nullptr) { |
|
|
|
|
errors->AddError("field not present"); |
|
|
|
|
} else { |
|
|
|
|
ValidationErrors::ScopedField field(errors, ".eds_config"); |
|
|
|
|
const envoy_config_core_v3_ConfigSource* eds_config = |
|
|
|
|
envoy_config_cluster_v3_Cluster_EdsClusterConfig_eds_config( |
|
|
|
|
eds_cluster_config); |
|
|
|
|
if (eds_config == nullptr) { |
|
|
|
|
errors->AddError("field not present"); |
|
|
|
|
} else { |
|
|
|
|
if (!envoy_config_core_v3_ConfigSource_has_ads(eds_config) && |
|
|
|
|
!envoy_config_core_v3_ConfigSource_has_self(eds_config)) { |
|
|
|
|
errors->AddError("ConfigSource is not ads or self"); |
|
|
|
|
} |
|
|
|
|
// Record EDS service_name (if any).
|
|
|
|
|
upb_StringView service_name = |
|
|
|
|
envoy_config_cluster_v3_Cluster_EdsClusterConfig_service_name( |
|
|
|
|
// Validate ConfigSource.
|
|
|
|
|
{ |
|
|
|
|
ValidationErrors::ScopedField field(errors, ".eds_config"); |
|
|
|
|
const envoy_config_core_v3_ConfigSource* eds_config = |
|
|
|
|
envoy_config_cluster_v3_Cluster_EdsClusterConfig_eds_config( |
|
|
|
|
eds_cluster_config); |
|
|
|
|
if (service_name.size != 0) { |
|
|
|
|
eds.eds_service_name = UpbStringToStdString(service_name); |
|
|
|
|
if (eds_config == nullptr) { |
|
|
|
|
errors->AddError("field not present"); |
|
|
|
|
} else { |
|
|
|
|
if (!envoy_config_core_v3_ConfigSource_has_ads(eds_config) && |
|
|
|
|
!envoy_config_core_v3_ConfigSource_has_self(eds_config)) { |
|
|
|
|
errors->AddError("ConfigSource is not ads or self"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// Record EDS service_name (if any).
|
|
|
|
|
// This field is required if the CDS resource has an xdstp name.
|
|
|
|
|
eds.eds_service_name = UpbStringToStdString( |
|
|
|
|
envoy_config_cluster_v3_Cluster_EdsClusterConfig_service_name( |
|
|
|
|
eds_cluster_config)); |
|
|
|
|
if (eds.eds_service_name.empty()) { |
|
|
|
|
absl::string_view cluster_name = |
|
|
|
|
UpbStringToAbsl(envoy_config_cluster_v3_Cluster_name(cluster)); |
|
|
|
|
if (absl::StartsWith(cluster_name, "xdstp:")) { |
|
|
|
|
ValidationErrors::ScopedField field(errors, ".service_name"); |
|
|
|
|
errors->AddError("must be set if Cluster resource has an xdstp name"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|