static BigtableConfig translateToBigtableConfig(BigtableConfig config, BigtableOptions options) {
    BigtableConfig.Builder builder = config.toBuilder();

    if (options.getProjectId() != null && config.getProjectId() == null) {
      builder.setProjectId(ValueProvider.StaticValueProvider.of(options.getProjectId()));
    }

    if (options.getInstanceId() != null && config.getInstanceId() == null) {
      builder.setInstanceId(ValueProvider.StaticValueProvider.of(options.getInstanceId()));
    }

    if (options.getAppProfileId() != null && config.getAppProfileId() == null) {
      builder.setAppProfileId(ValueProvider.StaticValueProvider.of(options.getAppProfileId()));
    }

    if (options.getCredentialOptions().getCredentialType() == CredentialOptions.CredentialType.None
        && config.getEmulatorHost() == null) {
      builder.setEmulatorHost(String.format("%s:%s", options.getDataHost(), options.getPort()));
    }

    builder.setChannelCount(options.getChannelCount());

    if (options.getCredentialOptions() != null) {
      try {
        CredentialOptions credOptions = options.getCredentialOptions();
        switch (credOptions.getCredentialType()) {
          case DefaultCredentials:
            // Veneer uses default credentials, so no need to reset here
            break;
          case P12:
            String keyFile = ((CredentialOptions.P12CredentialOptions) credOptions).getKeyFile();
            String serviceAccount =
                ((CredentialOptions.P12CredentialOptions) credOptions).getServiceAccount();
            try {
              KeyStore keyStore = KeyStore.getInstance("PKCS12");

              try (FileInputStream fin = new FileInputStream(keyFile)) {
                keyStore.load(fin, "notasecret".toCharArray());
              }
              PrivateKey privateKey =
                  (PrivateKey) keyStore.getKey("privatekey", "notasecret".toCharArray());

              if (privateKey == null) {
                throw new IllegalStateException("private key cannot be null");
              }
              Credentials credentials =
                  ServiceAccountJwtAccessCredentials.newBuilder()
                      .setClientEmail(serviceAccount)
                      .setPrivateKey(privateKey)
                      .build();
              builder.setCredentialFactory(FixedCredentialFactory.create(credentials));
            } catch (GeneralSecurityException exception) {
              throw new RuntimeException("exception while retrieving credentials", exception);
            }
            break;
          case SuppliedCredentials:
            Credentials credentials =
                ((CredentialOptions.UserSuppliedCredentialOptions) credOptions).getCredential();
            builder.setCredentialFactory(FixedCredentialFactory.create(credentials));
            break;
          case SuppliedJson:
            CredentialOptions.JsonCredentialsOptions jsonCredentialsOptions =
                (CredentialOptions.JsonCredentialsOptions) credOptions;
            builder.setCredentialFactory(
                FixedCredentialFactory.create(
                    GoogleCredentials.fromStream(jsonCredentialsOptions.getInputStream())));
            break;
          case None:
            // pipelineOptions is ignored
            PipelineOptions pipelineOptions = PipelineOptionsFactory.create();
            builder.setCredentialFactory(NoopCredentialFactory.fromOptions(pipelineOptions));
            break;
        }
      } catch (IOException e) {
        throw new RuntimeException("Failed to translate BigtableOptions to BigtableConfig", e);
      }
    }

    return builder.build();
  }
@Test
  public void testBigtableOptionsToBigtableConfig() throws Exception {
    BigtableOptions options =
        BigtableOptions.builder()
            .setProjectId("project")
            .setInstanceId("instance")
            .setAppProfileId("app-profile")
            .setDataHost("localhost")
            .setPort(1234)
            .setCredentialOptions(CredentialOptions.nullCredential())
            .build();

    BigtableConfig config = BigtableConfig.builder().setValidate(true).build();
    config = BigtableConfigTranslator.translateToBigtableConfig(config, options);

    assertNotNull(config.getProjectId());
    assertNotNull(config.getInstanceId());
    assertNotNull(config.getAppProfileId());
    assertNotNull(config.getEmulatorHost());
    assertNotNull(config.getCredentialFactory());

    NoopCredentialFactory noopCredentialFactory =
        NoopCredentialFactory.fromOptions(PipelineOptionsFactory.as(GcpOptions.class));
    assertEquals(options.getProjectId(), config.getProjectId().get());
    assertEquals(options.getInstanceId(), config.getInstanceId().get());
    assertEquals(options.getAppProfileId(), config.getAppProfileId().get());
    assertEquals("localhost:1234", config.getEmulatorHost());
    assertEquals(
        noopCredentialFactory.getCredential(), config.getCredentialFactory().getCredential());
  }