1212import io .envoyproxy .controlplane .cache .SnapshotResources ;
1313import io .envoyproxy .controlplane .cache .VersionedResource ;
1414import io .envoyproxy .envoy .config .cluster .v3 .Cluster ;
15+ import io .envoyproxy .envoy .config .core .v3 .TypedExtensionConfig ;
1516import io .envoyproxy .envoy .config .endpoint .v3 .ClusterLoadAssignment ;
1617import io .envoyproxy .envoy .config .listener .v3 .Listener ;
1718import io .envoyproxy .envoy .config .route .v3 .RouteConfiguration ;
@@ -46,6 +47,30 @@ public static Snapshot create(
4647 Iterable <Secret > secrets ,
4748 String version ) {
4849
50+ return create (clusters , endpoints , listeners , routes , secrets , Collections .emptySet (), version );
51+ }
52+
53+ /**
54+ * Returns a new {@link io.envoyproxy.controlplane.cache.v3.Snapshot} instance that is versioned uniformly across all
55+ * resources, including ECDS extension configs.
56+ *
57+ * @param clusters the cluster resources in this snapshot
58+ * @param endpoints the endpoint resources in this snapshot
59+ * @param listeners the listener resources in this snapshot
60+ * @param routes the route resources in this snapshot
61+ * @param secrets the secret resources in this snapshot
62+ * @param extensionConfigs the ECDS extension config resources in this snapshot
63+ * @param version the version associated with all resources in this snapshot
64+ */
65+ public static Snapshot create (
66+ Iterable <Cluster > clusters ,
67+ Iterable <ClusterLoadAssignment > endpoints ,
68+ Iterable <Listener > listeners ,
69+ Iterable <RouteConfiguration > routes ,
70+ Iterable <Secret > secrets ,
71+ Iterable <TypedExtensionConfig > extensionConfigs ,
72+ String version ) {
73+
4974 return new AutoValue_Snapshot (
5075 SnapshotResources
5176 .create (generateSnapshotResourceIterable (clusters ), version ),
@@ -56,7 +81,9 @@ public static Snapshot create(
5681 SnapshotResources
5782 .create (generateSnapshotResourceIterable (routes ), version ),
5883 SnapshotResources
59- .create (generateSnapshotResourceIterable (secrets ), version ));
84+ .create (generateSnapshotResourceIterable (secrets ), version ),
85+ SnapshotResources
86+ .create (generateSnapshotResourceIterable (extensionConfigs ), version ));
6087 }
6188
6289 /**
@@ -84,6 +111,41 @@ public static Snapshot create(
84111 Iterable <Secret > secrets ,
85112 String secretsVersion ) {
86113
114+ return create (clusters , clustersVersion , endpoints , endpointsVersion , listeners , listenersVersion ,
115+ routes , routesVersion , secrets , secretsVersion , Collections .emptySet (), "" );
116+ }
117+
118+ /**
119+ * Returns a new {@link io.envoyproxy.controlplane.cache.v3.Snapshot} instance that has separate versions for each
120+ * resource type, including ECDS extension configs.
121+ *
122+ * @param clusters the cluster resources in this snapshot
123+ * @param clustersVersion the version of the cluster resources
124+ * @param endpoints the endpoint resources in this snapshot
125+ * @param endpointsVersion the version of the endpoint resources
126+ * @param listeners the listener resources in this snapshot
127+ * @param listenersVersion the version of the listener resources
128+ * @param routes the route resources in this snapshot
129+ * @param routesVersion the version of the route resources
130+ * @param secrets the secret resources in this snapshot
131+ * @param secretsVersion the version of the secret resources
132+ * @param extensionConfigs the ECDS extension config resources in this snapshot
133+ * @param extensionConfigsVersion the version of the ECDS extension config resources
134+ */
135+ public static Snapshot create (
136+ Iterable <Cluster > clusters ,
137+ String clustersVersion ,
138+ Iterable <ClusterLoadAssignment > endpoints ,
139+ String endpointsVersion ,
140+ Iterable <Listener > listeners ,
141+ String listenersVersion ,
142+ Iterable <RouteConfiguration > routes ,
143+ String routesVersion ,
144+ Iterable <Secret > secrets ,
145+ String secretsVersion ,
146+ Iterable <TypedExtensionConfig > extensionConfigs ,
147+ String extensionConfigsVersion ) {
148+
87149 // TODO(snowp): add a builder alternative
88150 return new AutoValue_Snapshot (
89151 SnapshotResources .create (generateSnapshotResourceIterable (clusters ),
@@ -95,7 +157,9 @@ public static Snapshot create(
95157 SnapshotResources
96158 .create (generateSnapshotResourceIterable (routes ), routesVersion ),
97159 SnapshotResources .create (generateSnapshotResourceIterable (secrets ),
98- secretsVersion ));
160+ secretsVersion ),
161+ SnapshotResources .create (generateSnapshotResourceIterable (extensionConfigs ),
162+ extensionConfigsVersion ));
99163 }
100164
101165 /**
@@ -133,6 +197,11 @@ public static Snapshot createEmpty(String version) {
133197 */
134198 public abstract SnapshotResources <Secret > secrets ();
135199
200+ /**
201+ * Returns all extension config items in the ECDS payload.
202+ */
203+ public abstract SnapshotResources <TypedExtensionConfig > extensionConfigs ();
204+
136205 /**
137206 * Asserts that all dependent resources are included in the snapshot. All EDS resources are listed by name in CDS
138207 * resources, and all RDS resources are listed by name in LDS resources.
@@ -191,6 +260,8 @@ public Map<String, VersionedResource<?>> resources(String typeUrl) {
191260 return (Map ) routes ().resources ();
192261 case SECRET :
193262 return (Map ) secrets ().resources ();
263+ case EXTENSION_CONFIG :
264+ return (Map ) extensionConfigs ().resources ();
194265 default :
195266 return ImmutableMap .of ();
196267 }
@@ -213,6 +284,8 @@ public Map<String, VersionedResource<?>> versionedResources(ResourceType resourc
213284 return (Map ) routes ().versionedResources ();
214285 case SECRET :
215286 return (Map ) secrets ().versionedResources ();
287+ case EXTENSION_CONFIG :
288+ return (Map ) extensionConfigs ().versionedResources ();
216289 default :
217290 return ImmutableMap .of ();
218291 }
@@ -268,6 +341,8 @@ public String version(ResourceType resourceType, List<String> resourceNames) {
268341 return routes ().version (resourceNames );
269342 case SECRET :
270343 return secrets ().version (resourceNames );
344+ case EXTENSION_CONFIG :
345+ return extensionConfigs ().version (resourceNames );
271346 default :
272347 return "" ;
273348 }
0 commit comments