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

Fix the way of GitHub module handling #187

Merged
merged 1 commit into from
Apr 1, 2022
Merged

Fix the way of GitHub module handling #187

merged 1 commit into from
Apr 1, 2022

Conversation

mittz
Copy link
Contributor

@mittz mittz commented Mar 30, 2022

I would like to share my progress with you @tpdownes . I would appreciate if you could review my work and check if I'm going in the right direction.

1. Support Terraform modules at the root of GitHub repos

HPC Toolkit currently doesn't support modules at the root of GitHub repos when they are specified like below.

- source: github.com/terraform-google-modules/terraform-google-service-accounts
  kind: terraform
  id: central_manager

This will be fixed by this commit which is based on hashicorp/go-getter - Using git always gives error 128 #114.

2. Download remote modules only for the purpose of running terraform-config-inspect, and not save them into blueprints output directory

HPC Toolkit currently downloads modules from GitHub repos and saves them with URL parameters under modules directory in a blueprint directory when they are specified like below.

- source: github.com/terraform-google-modules/terraform-google-service-accounts.git?ref=v4.1.1
  kind: terraform
  id: central_manager

The current solution creates a git repository in a subdirectory of the blueprint. We anticipate that many users will want to manage blueprints with git. So, we are effectively requiring them to use git submodules ("git inside git"). Which is difficult. In addition, downloading GitHub modules is not required for Terraform and directory names with '?' and '=' are not safe in general, so this commit will update the tool to take the following actions:

  • Download modules from GitHub and run terraform-config-inspect in temp directory by ghpc.
  • Update output Terraform files with the original input GitHub path by ghpc.

Current output

module "central_manager" {
  source     = "./modules/terraform-google-service-accounts.git?ref=v4.1.1"
  project_id = var.project_id
}

Expected output

module "central_manager" {
  source     = "github.com/terraform-google-modules/terraform-google-service-accounts.git?ref=v4.1.1"
  project_id = var.project_id
}

Submission Checklist

  • Have you installed and run this change against pre-commit? pre-commit install
  • Are all tests passing? make tests
  • If applicable, have you written additional unit tests to cover this
    change?
  • Is unit test coverage still above 80%?
  • Have you updated any application documentation such as READMEs and user
    guides?
  • Have you followed the guidelines in our Contributing document?

@GoogleCloudPlatform GoogleCloudPlatform deleted a comment from tpdownes Mar 31, 2022
@cboneti cboneti requested a review from tpdownes March 31, 2022 22:42
@mittz mittz marked this pull request as ready for review April 1, 2022 08:14
@tpdownes tpdownes removed their assignment Apr 1, 2022
@tpdownes tpdownes merged commit 4bcc21c into GoogleCloudPlatform:develop Apr 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants