
Product
Introducing Supply Chain Attack Campaigns Tracking in the Socket Dashboard
Campaign-level threat intelligence in Socket now shows when active supply chain attacks affect your repositories and packages.
Reformat HCL ⇄ JSON and HCL ⇄ YAML.
$ go get github.com/rjeczalik/refmt
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.
# build the refmt image
docker build -t refmt .
# convert test.yml to hcl
cat test.yml | docker run -i --rm refmt -t hcl - -
$ 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"
}
$ refmt main.tf.json main.tf.json
$ 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
FAQs
Unknown package
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Campaign-level threat intelligence in Socket now shows when active supply chain attacks affect your repositories and packages.

Research
Malicious PyPI package sympy-dev targets SymPy users, a Python symbolic math library with 85 million monthly downloads.

Security News
Node.js 25.4.0 makes require(esm) stable, formalizing CommonJS and ESM compatibility across supported Node versions.