Skip to content

Commit

Permalink
revert NoServicesFoundException
Browse files Browse the repository at this point in the history
  • Loading branch information
diegomarquezp committed Feb 12, 2024
1 parent 00c1eb1 commit d150747
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package com.google.api.generator;

import com.google.api.generator.gapic.Generator;
import com.google.api.generator.gapic.protoparser.NoServicesFoundException;
import com.google.protobuf.ExtensionRegistry;
import com.google.protobuf.compiler.PluginProtos.CodeGeneratorRequest;
import com.google.protobuf.compiler.PluginProtos.CodeGeneratorResponse;
Expand All @@ -26,12 +25,7 @@ public static void main(String[] args) throws IOException {
ExtensionRegistry registry = ExtensionRegistry.newInstance();
ProtoRegistry.registerAllExtensions(registry);
CodeGeneratorRequest request = CodeGeneratorRequest.parseFrom(System.in, registry);
try {
CodeGeneratorResponse response = Generator.generateGapic(request);
response.writeTo(System.out);
} catch (NoServicesFoundException ex) {
// If no services are found in the protos we will no-op
System.err.println("No services found to generate");
}
CodeGeneratorResponse response = Generator.generateGapic(request);
response.writeTo(System.out);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,19 @@

package com.google.api.generator.gapic;

import com.google.api.gax.rpc.StatusCode.Code;
import com.google.api.generator.gapic.composer.Composer;
import com.google.api.generator.gapic.model.GapicClass;
import com.google.api.generator.gapic.model.GapicContext;
import com.google.api.generator.gapic.model.GapicPackageInfo;
import com.google.api.generator.gapic.model.ReflectConfig;
import com.google.api.generator.gapic.protoparser.NoServicesFoundException;
import com.google.api.generator.gapic.protoparser.Parser;
import com.google.api.generator.gapic.protowriter.Writer;
import com.google.protobuf.compiler.PluginProtos.CodeGeneratorRequest;
import com.google.protobuf.compiler.PluginProtos.CodeGeneratorResponse;
import java.util.List;

public class Generator {
public static CodeGeneratorResponse generateGapic(CodeGeneratorRequest request)
throws NoServicesFoundException {
public static CodeGeneratorResponse generateGapic(CodeGeneratorRequest request) {
GapicContext context = Parser.parse(request);
List<GapicClass> clazzes = Composer.composeServiceClasses(context);
GapicPackageInfo packageInfo = Composer.composePackageInfo(context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import com.google.api.generator.gapic.model.GapicPackageInfo;
import com.google.api.generator.gapic.model.Sample;
import com.google.api.generator.gapic.model.Service;
import com.google.api.generator.gapic.protoparser.NoServicesFoundException;
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import javax.annotation.Generated;

Expand All @@ -44,9 +44,8 @@ public class ClientLibraryPackageInfoComposer {
private static final String SERVICE_DESCRIPTION_HEADER_PATTERN = "Service Description: %s";

public static GapicPackageInfo generatePackageInfo(GapicContext context) {
if (context.services().isEmpty()) {
throw new NoServicesFoundException("No services found to generate");
}
Preconditions.checkState(!context.services().isEmpty(), "No services found to generate");

// Pick some service's package, as we assume they are all the same.
String libraryPakkage = context.services().get(0).pakkage();

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public GapicParserException(String errorMessage) {
}
}

public static GapicContext parse(CodeGeneratorRequest request) throws NoServicesFoundException {
public static GapicContext parse(CodeGeneratorRequest request) {
Optional<String> gapicYamlConfigPathOpt =
PluginArgumentParser.parseGapicYamlConfigPath(request);
Optional<List<GapicBatchingSettings>> batchingSettingsOpt =
Expand Down Expand Up @@ -176,7 +176,7 @@ public static GapicContext parse(CodeGeneratorRequest request) throws NoServices
transport);

if (services.isEmpty()) {
throw new NoServicesFoundException();
//throw new NoServicesFoundException();
}

// TODO(vam-google): Figure out whether we should keep this allowlist or bring
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import com.google.protobuf.Descriptors.FileDescriptor;
import com.google.protobuf.Descriptors.MethodDescriptor;
import com.google.protobuf.Descriptors.ServiceDescriptor;
import com.google.protobuf.compiler.PluginProtos.CodeGeneratorRequest;
import com.google.showcase.v1beta1.EchoOuterClass;
import com.google.showcase.v1beta1.TestingOuterClass;
import com.google.testgapic.v1beta1.LockerProto;
Expand Down

0 comments on commit d150747

Please sign in to comment.