Skip to content

Commit 804cb09

Browse files
committed
Fixup 12492: Eliminate bootstrap dependency on grpc
1 parent 779b8ed commit 804cb09

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed

xds/src/main/java/io/grpc/xds/GrpcBootstrapperImpl.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,11 @@ private static ConfiguredChannelCredentials parseChannelCredentials(List<Map<Str
173173
}
174174

175175
@Override
176-
protected Object parseAllowedGrpcServices(
177-
Map<String, ?> rawAllowedGrpcServices)
176+
protected Optional<Object> parseAllowedGrpcServices(
177+
@Nullable Map<String, ?> rawAllowedGrpcServices)
178178
throws XdsInitializationException {
179179
if (rawAllowedGrpcServices == null || rawAllowedGrpcServices.isEmpty()) {
180-
return AllowedGrpcServices.empty();
180+
return Optional.of(AllowedGrpcServices.empty());
181181
}
182182

183183
ImmutableMap.Builder<String, AllowedGrpcService> builder =
@@ -203,7 +203,7 @@ protected Object parseAllowedGrpcServices(
203203
callCredentials.ifPresent(b::callCredentials);
204204
builder.put(targetUri, b.build());
205205
}
206-
return AllowedGrpcServices.create(builder.build());
206+
return Optional.of(AllowedGrpcServices.create(builder.build()));
207207
}
208208

209209
@SuppressWarnings("unused")

xds/src/main/java/io/grpc/xds/client/Bootstrapper.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
import com.google.common.collect.ImmutableMap;
2525
import io.grpc.Internal;
2626
import io.grpc.xds.client.EnvoyProtoData.Node;
27-
import io.grpc.xds.internal.grpcservice.AllowedGrpcServices;
2827
import java.util.List;
2928
import java.util.Map;
29+
import java.util.Optional;
3030
import javax.annotation.Nullable;
3131

3232
/**
@@ -210,14 +210,14 @@ public abstract static class BootstrapInfo {
210210
* Parsed allowed_grpc_services configuration.
211211
* Returns an opaque object containing the parsed configuration.
212212
*/
213-
public abstract Object allowedGrpcServices();
213+
public abstract Optional<Object> allowedGrpcServices();
214214

215215
@VisibleForTesting
216216
public static Builder builder() {
217217
return new AutoValue_Bootstrapper_BootstrapInfo.Builder()
218218
.clientDefaultListenerResourceNameTemplate("%s")
219219
.authorities(ImmutableMap.<String, AuthorityInfo>of())
220-
.allowedGrpcServices(AllowedGrpcServices.empty());
220+
.allowedGrpcServices(Optional.empty());
221221
}
222222

223223
@AutoValue.Builder
@@ -239,7 +239,7 @@ public abstract Builder clientDefaultListenerResourceNameTemplate(
239239

240240
public abstract Builder authorities(Map<String, AuthorityInfo> authorities);
241241

242-
public abstract Builder allowedGrpcServices(Object allowedGrpcServices);
242+
public abstract Builder allowedGrpcServices(Optional<Object> allowedGrpcServices);
243243

244244
public abstract BootstrapInfo build();
245245
}

xds/src/main/java/io/grpc/xds/client/BootstrapperImpl.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
import java.util.HashMap;
3535
import java.util.List;
3636
import java.util.Map;
37+
import java.util.Optional;
38+
import javax.annotation.Nullable;
3739

3840
/**
3941
* A {@link Bootstrapper} implementation that reads xDS configurations from local file system.
@@ -245,10 +247,10 @@ protected BootstrapInfo.Builder bootstrapBuilder(Map<String, ?> rawData)
245247
return builder;
246248
}
247249

248-
protected Object parseAllowedGrpcServices(
249-
Map<String, ?> rawAllowedGrpcServices)
250+
protected Optional<Object> parseAllowedGrpcServices(
251+
@Nullable Map<String, ?> rawAllowedGrpcServices)
250252
throws XdsInitializationException {
251-
return io.grpc.xds.internal.grpcservice.AllowedGrpcServices.empty();
253+
return Optional.empty();
252254
}
253255

254256
private List<ServerInfo> parseServerInfos(List<?> rawServerConfigs, XdsLogger logger)

xds/src/test/java/io/grpc/xds/GrpcBootstrapperImplTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public void parseBootstrap_allowedGrpcServices() throws XdsInitializationExcepti
118118

119119
bootstrapper.setFileReader(createFileReader(BOOTSTRAP_FILE_PATH, rawData));
120120
BootstrapInfo info = bootstrapper.bootstrap();
121-
AllowedGrpcServices allowed = (AllowedGrpcServices) info.allowedGrpcServices();
121+
AllowedGrpcServices allowed = (AllowedGrpcServices) info.allowedGrpcServices().get();
122122
assertThat(allowed).isNotNull();
123123
assertThat(allowed.services()).containsKey("dns:///foo.com:443");
124124
AllowedGrpcService service = allowed.services().get("dns:///foo.com:443");

0 commit comments

Comments
 (0)