Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow customizing context_name, default to the same as gcloud #159

Merged
merged 1 commit into from
Dec 15, 2021

Conversation

sethvargo
Copy link
Member

Fixes #86

@sethvargo sethvargo requested a review from a team as a code owner December 14, 2021 18:11
src/main.ts Outdated
const location = getInput('location', { required: true });
const credentials = getInput('credentials');
const projectId = getInput('project_id');
const useAuthProvider = getBooleanInput('use_auth_provider');
const useInternalIP = getBooleanInput('use_internal_ip');
const contextName = getInput('context_name') || `gke_${projectId}_${location}_${clusterName}`;
Copy link
Member Author

Choose a reason for hiding this comment

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

🐉 for discussion. This changes the default to match gcloud's default naming, but it changes the existing behavior for default naming.

Copy link
Contributor

Choose a reason for hiding this comment

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

IMO switching to gcloud default should be okay. However projectId is not a required input and maybe empty here as we support discovery via GCLOUD_PROJECT

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point. Can we merge #160 first since it has the nicer project ID extraction at this layer?

Copy link
Contributor

Choose a reason for hiding this comment

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

@sethvargo Just merged #160

Copy link
Member Author

Choose a reason for hiding this comment

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

Done - this logic gets a little circular, so please take a close look

@@ -57,15 +60,42 @@ async function run(): Promise<void> {

// Pick the best project ID.
if (!projectID) {
if (credentialsJSON && isServiceAccountKey(credentialsJSON)) {
if (clusterName.projectID) {
Copy link
Member Author

Choose a reason for hiding this comment

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

I set the order of precedence here to be:

  1. Project ID as an input
  2. Project ID in the resource name
  3. Project ID from credentials
  4. Environment variable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Option to rename the generated kubectl context
2 participants