Skip to content
This repository has been archived by the owner on Nov 11, 2022. It is now read-only.

Try to find the active gcloud config #348

Closed

Conversation

ravwojdyla
Copy link
Contributor

No description provided.

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please let us know the company's name.

@dhalperi
Copy link
Contributor

Hi Rafal,

Thanks -- this looks like a nice improvement.

It looks like it will apply equally well to Apache Beam (incubating), which will be the foundation for this SDK starting in version 2.0. We are try to add new features in Beam first, then backport them here -- this prevents future regressions.

Would you mind starting this PR there, and then we can backport it here? The Beam Contribution Guide is the place to get started.

Thanks!
Dan

@dhalperi dhalperi added cla: yes and removed cla: no labels Jul 29, 2016
@dhalperi
Copy link
Contributor

CLA confirmed for Spotify.

// get active configuration
File activeConfFile = new File(
getUserHome(),
".config/gcloud/active_config");
Copy link
Contributor

@lukecwik lukecwik Jul 29, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do the paths specified in these locations work on windows?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question - there is if branch for windows before, also previous version of the code assumed the same hierarchy for all platforms (here). What would you suggest?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems as though Google is vending a library that already does this and instead of Dataflow owning this logic, we can rely on this library but wanted to make sure that this meets your needs:

https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/gcloud-java-core/src/main/java/com/google/cloud/ServiceOptions.java
Look at the logic for defaultProject(), specifically activeGoogleCloudConfig() and googleCloudProjectId()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @lukecwik - was on vacation. I see, thanks for the gcloud-java link, I looked at the code, and it's pretty much the same. afaiu current DF does not check for:

    String projectId = System.getProperty(PROJECT_ENV_NAME, System.getenv(PROJECT_ENV_NAME));
    if (projectId == null) {
      projectId = appEngineProjectId();
    }
    if (projectId == null) {
      projectId = serviceAccountProjectId();
    }

Specifically serviceAccountProjectId could be interesting, afaiu it would discover if user is using a service account through GOOGLE_APPLICATION_CREDENTIALS and then if available, fetch the project from the credentials file. One could argue if that is good or bad idea, probably good for defaultProject.

It seems like we could push this PR, I could submit PR to gcloud-java to abstract the project discover logic away from ServiceOptions, then I could submit another PR to DF to start using gcloud-java? Does it sound like a good plan?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ping @lukecwik

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ping 2x @lukecwik - do you think we should wait for google-cloud-java or move forward?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would wait for google-cloud-java, it seems as though they are working towards the change as evidenced on googleapis/google-cloud-java#1207

@ravwojdyla
Copy link
Contributor Author

@dhalperi sure - will open PR in the Beam. Will finialize comments with @lukecwik here first tho.

@googlebot googlebot added cla: no and removed cla: yes labels Aug 2, 2016
@ravwojdyla ravwojdyla force-pushed the gcloud_active_config branch from 898e3d6 to 4261b7b Compare August 19, 2016 09:00
@lukecwik
Copy link
Contributor

Opened up googleapis/google-cloud-java#1207

@lukecwik
Copy link
Contributor

This is superseded by the follow feature request on Apache Beam 2.x:
https://issues.apache.org/jira/browse/BEAM-2391

@lukecwik lukecwik closed this May 30, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants