All Projects → rjeczalik → refmt

rjeczalik / refmt

Licence: AGPL-3.0 License
Reformat HCL ⇄ JSON ⇄ YAML.

Programming Languages

go
31211 projects - #10 most used programming language
Dockerfile
14818 projects

Projects that are alternatives of or similar to refmt

Libvirt K8s Provisioner
Automate your k8s installation
Stars: ✭ 106 (+457.89%)
Mutual labels:  hcl, kubectl
Config Lint
Command line tool to validate configuration files
Stars: ✭ 118 (+521.05%)
Mutual labels:  yaml, hcl
Jk
Configuration as Code with ECMAScript
Stars: ✭ 322 (+1594.74%)
Mutual labels:  yaml, hcl
Terraform Eks
Terraform for AWS EKS
Stars: ✭ 82 (+331.58%)
Mutual labels:  hcl, kubectl
kahoy
Simple Kubernetes raw manifests deployment tool
Stars: ✭ 33 (+73.68%)
Mutual labels:  yaml, kubectl
K2tf
Kubernetes YAML to Terraform HCL converter
Stars: ✭ 477 (+2410.53%)
Mutual labels:  yaml, hcl
Resticprofile
Configuration profiles for restic backup
Stars: ✭ 48 (+152.63%)
Mutual labels:  yaml, hcl
Tfk8s
A tool for converting Kubernetes YAML manifests to Terraform HCL
Stars: ✭ 167 (+778.95%)
Mutual labels:  yaml, hcl
wildq
Command-line TOML/JSON/INI/YAML/XML/HCL processor using jq c bindings
Stars: ✭ 22 (+15.79%)
Mutual labels:  yaml, hcl
Config
📝 Go config manage(load,get,set). support JSON, YAML, TOML, INI, HCL, ENV and Flags. Multi file load, data override merge, parse ENV var. Go应用配置加载管理,支持多种格式,多文件加载,远程文件加载,支持数据合并,解析环境变量名
Stars: ✭ 225 (+1084.21%)
Mutual labels:  yaml, hcl
transfer
Converts from one encoding to another. Supported formats HCL ⇄ JSON ⇄ YAML⇄TOML⇄XML⇄plist⇄pickle⇄properties ...
Stars: ✭ 70 (+268.42%)
Mutual labels:  yaml, hcl
stein
A linter for config files with a customizable rule set
Stars: ✭ 92 (+384.21%)
Mutual labels:  yaml, hcl
parse it
A python library for parsing multiple types of config files, envvars & command line arguments that takes the headache out of setting app configurations.
Stars: ✭ 86 (+352.63%)
Mutual labels:  yaml, hcl
PotentCodables
🧪 PotentCodables - A potent set of implementations and extensions to the Swift Codable system
Stars: ✭ 32 (+68.42%)
Mutual labels:  yaml
front
Frontmatter
Stars: ✭ 21 (+10.53%)
Mutual labels:  yaml
doo
简单易用的接口管理解决方案,支持接口文档管理、Mock服务,接口测试等功能。接口文档采用 yaml 或 Excel 格式书写,简单快捷,Mock 基于该文档,无需数据库,一条命令秒变 Mock 服务。
Stars: ✭ 36 (+89.47%)
Mutual labels:  yaml
CoreFormatters
.NET Core Custom Formatter for Yaml
Stars: ✭ 21 (+10.53%)
Mutual labels:  yaml
yaml
A Laravel YAML parser and config loader
Stars: ✭ 100 (+426.32%)
Mutual labels:  yaml
k8s-opa-boilerplate
Boilerplate example of managing OPA with kustomize
Stars: ✭ 14 (-26.32%)
Mutual labels:  yaml
website
Prometheus monitoring mixins
Stars: ✭ 91 (+378.95%)
Mutual labels:  yaml

refmt GoDoc Build Status Build status

Reformat HCL ⇄ JSON and HCL ⇄ YAML.

install

$ go get github.com/rjeczalik/refmt

usage

usage:

	refmt [-t type] INPUT_FILE|"-" OUTPUT_FILE|"-"

Converts from one encoding to another. Supported formats (and their file extensions):

	- HCL (.hcl or .tf)
	- JSON (.json)
	- YAML (.yaml or .yml)

If INPUT_FILE's extension is not recognized or INPUT_FILE is "-" (stdin),
refmt will try to guess input format.

If OUTPUT_FILE is "-" (stdout), destination format type is required to be
passed with -t flag.

	refmt [-t type] merge ORIGINAL_FILE|"-" MIXIN_FILE|"-" OUTPUT_FILE|"-"

Merges the object defined in ORIGINAL_FILE with the object from MIXIN_FILE, writing
the resulting object to the OUTPUT_FILE.

The ORIGINAL_FILE, MIXIN_FILE and OUTPUT_FILE can have different encodings.

If ORIGINAL_FILE's extension is not recognized or ORIGINAL_FILE is "-" (stdin),
refmt will try to guess original format.

If ORIGINAL_FILE does not exist or is empty, refmt is going to use empty
object instead.

If MIXIN_FILE's extension is not recognized or MIXIN_FILE is "-" (stdin),
refmt will try to guess mixin format.

If OUTPUT_FILE is "-" (stdout), destination format type is required to be
passed with -t flag.

docker usage

# build the refmt image
docker build -t refmt .

# convert test.yml to hcl
cat test.yml | docker run -i --rm refmt -t hcl - -

examples

$ refmt -t yaml main.yaml -
provider:
  aws:
    access_key: ${var.aws_access_key}
    secret_key: ${var.aws_secret_key}
resource:
  aws_instance:
    aws-instance:
      instance_type: t2.nano
      user_data: echo "hello world!" >> /tmp/helloworld.txt
$ refmt main.yaml main.json
{
        "provider": {
                "aws": {
                        "access_key": "${var.aws_access_key}",
                        "secret_key": "${var.aws_secret_key}"
                }
        },
        "resource": {
                "aws_instance": {
                        "aws-instance": {
                                "instance_type": "t2.nano",
                                "user_data": "echo \"hello world!\" >> /tmp/helloworld.txt"
                        }
                }
        }
}
$ refmt main.json main.hcl
provider "aws" {
  access_key = "${var.aws_access_key}"
  secret_key = "${var.aws_secret_key}"
}

resource "aws_instance" "aws-instance" {
  instance_type = "t2.nano"
  user_data = "echo \"hello world!\" >> /tmp/helloworld.txt"
}

pretty reformat in-place

$ refmt main.tf.json main.tf.json

merge configurations

$ cat ~/.kube/config
apiVersion: v1
clusters:
- cluster:
    certificate-authority: /Volumes/rjk.io/.kube/ca.pem
    server: https://178.0.20.1
  name: default-cluster
contexts:
- context:
    cluster: default-cluster
    user: default-admin
  name: default-system
current-context: default-system
kind: Config
preferences: {}
users:
- name: default-admin
  user:
    client-certificate: /Volumes/rjk.io/.kube/admin.pem
    client-key: /Volumes/rjk.io/.kube/admin-key.pem
$ cat >>another-cluster <<EOF
apiVersion: v1
clusters:
- cluster:
    certificate-authority: /Volumes/rjk.io/.kube/another-ca.pem
    server: https://10.0.0.1
  name: another-cluster
contexts:
- context:
    cluster: another-cluster
    user: another-admin
  name: another-system
current-context: another-system
kind: Config
preferences: {}
users:
- name: another-admin
  user:
    client-certificate: /Volumes/rjk.io/.kube/another-admin.pem
    client-key: /Volumes/rjk.io/.kube/another-admin-key.pem
EOF
$ refmt merge -t yaml ~/.kube/config ./another-cluster -
apiVersion: v1
clusters:
- cluster:
    certificate-authority: /Volumes/rjk.io/.kube/ca.pem
    server: https://178.0.20.1
  name: default-cluster
- cluster:
    certificate-authority: /Volumes/rjk.io/.kube/another-ca.pem
    server: https://10.0.0.1
  name: another-cluster
contexts:
- context:
    cluster: default-cluster
    user: default-admin
  name: default-system
- context:
    cluster: another-cluster
    user: another-admin
  name: another-system
current-context: another-system
kind: Config
preferences: {}
users:
- name: default-admin
  user:
    client-certificate: /Volumes/rjk.io/.kube/admin.pem
    client-key: /Volumes/rjk.io/.kube/admin-key.pem
- name: another-admin
  user:
    client-certificate: /Volumes/rjk.io/.kube/another-admin.pem
    client-key: /Volumes/rjk.io/.kube/another-admin-key.pem

todo

  • inline docs
  • fix hcl marshaling:
    • fix excessive newlines
    • fix excessive quotes
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].