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

generate/hcl: support module calls through source keyword #67

Closed
wants to merge 7 commits into from

Conversation

tormath1
Copy link
Contributor

@tormath1 tormath1 commented Oct 28, 2020

In this PR, we add the support for module calls. It supports local, remote and Terraform registry ones.

The function moduleInstall is called recursively in order to walk through the ModuleCalls of each module to feed a ManagedResource slice. It stores a trace of each installed element to avoid infinite loops and modules are cached into $XDG_CACHE directory.

Then it loops over the ManagedResource slice with the current behavior.

A few notes:

  1. I'd like to use in-memory FS rather than actual FS but go-getter needs to be updated consequently (Abstract the os access via interface hashicorp/go-getter#83: I started to work on it btw)
  2. I still need to find a way to properly testing this :)

Output example using this stack: https://github.com/cycloid-community-catalog/stack-gke

$ ./inframap generate --hcl generate/testdata/stack-gke
strict digraph G {
        "google_container_node_pool.pools"->"google_container_cluster.primary";
        "null_resource.delete_default_kube_dns_configmap"->"google_container_cluster.primary";
        "null_resource.delete_default_kube_dns_configmap"->"google_container_node_pool.pools";
        "kubernetes_config_map.kube-dns-upstream-namservers"->"null_resource.delete_default_kube_dns_configmap";
        "kubernetes_config_map.kube-dns-upstream-namservers"->"google_container_cluster.primary";
        "kubernetes_config_map.kube-dns-upstream-namservers"->"google_container_node_pool.pools";
        "kubernetes_config_map.kube-dns-upstream-nameservers-and-stub-domains"->"null_resource.delete_default_kube_dns_configmap";
        "kubernetes_config_map.kube-dns-upstream-nameservers-and-stub-domains"->"google_container_cluster.primary";
        "kubernetes_config_map.kube-dns-upstream-nameservers-and-stub-domains"->"google_container_node_pool.pools";
        "kubernetes_config_map.ip-masq-agent"->"google_container_cluster.primary";
        "kubernetes_config_map.ip-masq-agent"->"google_container_node_pool.pools";
        "null_resource.wait_for_cluster"->"google_container_cluster.primary";
        "null_resource.wait_for_cluster"->"google_container_node_pool.pools";
        "google_service_account.cluster_service_account"->"random_string.cluster_service_account_suffix";
        "kubernetes_config_map.kube-dns"->"null_resource.delete_default_kube_dns_configmap";
        "kubernetes_config_map.kube-dns"->"google_container_cluster.primary";
        "kubernetes_config_map.kube-dns"->"google_container_node_pool.pools";
        "google_container_cluster.primary" [ shape=ellipse ];
        "google_container_node_pool.pools" [ shape=ellipse ];
        "google_service_account.cluster_service_account" [ shape=ellipse ];
        "kubernetes_config_map.ip-masq-agent" [ shape=ellipse ];
        "kubernetes_config_map.kube-dns" [ shape=ellipse ];
        "kubernetes_config_map.kube-dns-upstream-nameservers-and-stub-domains" [ shape=ellipse ];
        "kubernetes_config_map.kube-dns-upstream-namservers" [ shape=ellipse ];
        "null_resource.delete_default_kube_dns_configmap" [ shape=ellipse ];
        "null_resource.wait_for_cluster" [ shape=ellipse ];
        "random_string.cluster_service_account_suffix" [ shape=ellipse ];

}

@tormath1 tormath1 added the enhancement New feature or request label Oct 28, 2020
@tormath1 tormath1 self-assigned this Oct 28, 2020
@tibeer
Copy link

tibeer commented Apr 22, 2021

This change looks fine to me. May I ask why there hasn't been any progress on this?

@tormath1
Copy link
Contributor Author

hi @tibeer , progress was stopped because go-getter still does not support in-memory FS. We could try to merge it in this current state then. I opened a new PR (#130) because I changed change my source branch from this repo to my fork, rebase has been done too. cc @xescugc

@tormath1 tormath1 closed this Apr 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants