code: public boolean hasComponent(SdkComponent component) throws ManagedSdkVerificationException {
      if (!Files.isRegularFile(getGcloudPath())) {
        return false;
      }
  
      List<String> listComponentCommand =
          Arrays.asList(
              getGcloudPath().toString(),
              "components",
              "list",
              "--only-local-state",
              "--format=json",
              "--filter=id:" + component);
  
      try {
        String result = CommandCaller.newCaller().call(listComponentCommand, null, null);
        List<CloudSdkComponent> components = CloudSdkComponent.fromJsonList(result);
        if (components.size() > 1) {
          // not a unique component id
          throw new ManagedSdkVerificationException("Invalid component " + component);
        }
        return !components.isEmpty();
      } catch (CommandExecutionException | InterruptedException | CommandExitException ex) {
        throw new ManagedSdkVerificationException(ex);
      }
    }
docs: Query gcloud to see if component is installed. Uses gcloud's '--local-state-only' to avoid
  network accesses.