terrafmtter

command module
v0.0.0-...-dc5593a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 5, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

README

terrafmtter

OSCS Status

Terraform code generation tool by Alibaba Cloud Container Service for Kubernetes (ACK).

NOTE:

  • It's only for MacOS now.

Requirements

  • GoLang version 1.17+
  • Git
  • Network with access to GitHub

Install

You could install this tool by git.

mkdir -p $GOPATH/src/github.com/Pangjiping
cd $GOPATH/src/github.com/Pangjiping
git clone git@github.com:Pangjiping/terrafmtter.git
cd terrafmtter
make install

Usage

We will add the executable file to your environment variables during installation. So you could run terrafmtter in any directory. terrafmtter supports four command line arguments:

  • resource: It's required. You could select multiple resources which you want to create, like cs_kubernetes,cs_kubernetes_node_pool. Please use , to separate multiple resources.
  • data: It's required. You could select multiple datasources which you want to query, like cs_kubernetes_version,cs_kubernetes_clusters. Please use , to separate multiple datasources.
  • version: It's optional. You could specify the alicloud-provider version like 1.173.0. It's will be latest version if not assigned.
  • file: It's optional. You could specify the location of the output terraform file.

Below is a simple use case for terrafmtter:

terrafmtter --data cs_kubernetes_version \
--version 1.173.0 \
--file main.tf

The auto-generated main.tf is follows:

# Code generated by Alibaba Cloud Container Service for Kubernetes.
# More in https://www.alibabacloud.com/product/kubernetes
# We would not try to get your accessKey and secretKey for safety.
# PLEASE EDIT TODOs as needed. ^_^

# [TODO] PLEASE EDIT your secret information.
# Details in https://registry.terraform.io/providers/aliyun/alicloud/latest/docs
provider "alicloud" {
    access_key = "********"
    secret_key = "********"
    region = "cn-hangzhou"
}

# [TODO] PLEASE EDIT.
variable "default" {
    default = "tf-create"
}


# [TODO] PLEASE EDIT.
# Details in https://registry.terraform.io/providers/aliyun/alicloud/1.173.0/docs/data-sources/cs_kubernetes_version
data "alicloud_cs_kubernetes_version" "default" {

  # Details in https://registry.terraform.io/providers/aliyun/alicloud/1.173.0/docs/data-sources/cs_kubernetes_version#cluster_type
  cluster_type = "TODO"
  # Details in https://registry.terraform.io/providers/aliyun/alicloud/1.173.0/docs/data-sources/cs_kubernetes_version#version
  version = "TODO"
  # Details in https://registry.terraform.io/providers/aliyun/alicloud/1.173.0/docs/data-sources/cs_kubernetes_version#profile
  profile = "TODO"

}

Enhancements for ack (future)

  • auto attach resource and datasource.
  • set recommended fields.
  • full field enumeration.

TODOs

  • template enhancement.
  • setting default value.
  • optimize optional and required.
  • optimize for ack.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL