Test cases / yaml

deft yaml convert

Change format: --to json|toml|xml|jsonl

2 runs on real files, 6 tests on generated files, not shown. 0 failed.

Fixed cases

Generated files, compared with ground truth by tools other than deft.

a real Kubernetes deploymentPassed

deft yaml convert frontend-deployment.yaml --to json -o out.json

Input

apiVersion: apps/v1 #  for k8s versions before 1.9.0 use apps/v1beta2  and before 1.8.0 use extensions/v1beta1
kind: Deployment
metadata:
  name: frontend
spec:
  selector:
    matchLabels:
      app: guestbook
      tier: frontend
  replicas: 3
  template:
    metadata:
      labels:
        app: guestbook
        tier: frontend
    spec:
      containers:
      - name: php-redis
        image: gcr.io/google-samples/gb-frontend:v5
        resources:
          requests:
            cpu: 100m
            memory: 100Mi
          limits:
            cpu: 200m
            memory: 100Mi
        
        env:
        - name: GET_HOSTS_FROM
          value: dns
          # If your cluster config does not include a dns service, then to
          # instead access environment variables to find service host
          # info, comment out the 'value: dns' line above, and uncomment the
          # line below:
          # value: env
        ports:
        - containerPort: 80
        readinessProbe:
          httpGet:
            path: /
            port: 80
          initialDelaySeconds: 5
          periodSeconds: 10
        livenessProbe:
          httpGet:
            path: /
            port: 80
          initialDelaySeconds: 15
          periodSeconds: 20

Output

out.json 1.5 KB
{
  "apiVersion": "apps/v1",
  "kind": "Deployment",
  "metadata": {
    "name": "frontend"
  },
  "spec": {
    "selector": {
      "matchLabels": {
        "app": "guestbook",
        "tier": "frontend"
      }
    },
    "replicas": 3,
    "template": {
      "metadata": {
        "labels": {
          "app": "guestbook",
          "tier": "frontend"
        }
      },
      "spec": {
        "containers": [
          {
            "name": "php-redis",
            "image": "gcr.io/google-samples/gb-frontend:v5",
            "resources": {
              "requests": {
                "cpu": "100m",
                "memory": "100Mi"
              },
              "limits": {
                "cpu": "200m",
                "memory": "100Mi"
              }
            },
            "env": [
              {
                "name": "GET_HOSTS_FROM",
                "value": "dns"
              }
            ],
            "ports": [
              {
                "containerPort": 80
              }
            ],
            "readinessProbe": {
              "httpGet": {
                "path": "/",
                "port": 80
              },
              "initialDelaySeconds": 5,
              "periodSeconds": 10
            },
            "livenessProbe": {
              "httpGet": {
                "path": "/",
                "port": 80
              },
              "initialDelaySeconds": 15,
              "periodSeconds": 20
            }
          }
        ]
      }
    }
  }
}
What it printed
ok yaml.convert frontend-deployment.yaml -> out.json  1KB  0.01s
warning: comments are not kept
Automatic checks (1)
  • python: code = "import json; d = json.load(open('out.json')); assert d['kind'] == 'Deployment' and d['spec']['replicas'] > 0, d"

Real-file tasks

Real files and a plain-language job, from the agent benchmark. These are the reference answers, not an agent run.

YAML to JSONPassed

Convert config.yaml to config.json.

deft yaml convert config.yaml -o config.json

Input

config.yaml 16.0 KB
# Artifact Hub Chart default configuration values

# Common labels to add to all resources
commonLabels: {}

imagePullSecrets: []
imageTag: ""
nameOverride: ""
pullPolicy: IfNotPresent
nodeSelector: {}
tolerations: []

# Enable dynamic resource name prefix
#
# Enabling the dynamic resource name prefix ensures that the resources are named dynamically based on the Helm
# installation's name. This allows multiple installations of this chart in a single Kubernetes namespace. The prefix
# can be defined by using the `fullnameOverride`.
dynamicResourceNamePrefixEnabled: false

# Overwrites the installation's fullname generation (used for the dynamic resource name prefix)
fullnameOverride: ""

# Enable restricted HTTP client
#
# Artifact Hub makes external HTTP requests for several purposes, like getting repositories metadata, dispatching
# webhooks, etc. When this option is enabled, requests to the private network space as well as to some other special
# addresses won't be allowed.
restrictedHTTPClient: false

# Logging configuration
log:
  # Log level
  # Options: "trace", "debug", "info", "warn", "error", "fatal", "panic"
  level: info
  # Enable pretty logging
  pretty: false

# Database configuration
db:
  host: ""
  port: "5432"
  database: hub
  user: hub
  password: hub
  sslmode: prefer

# Email configuration
email:
  # From name used in emails
  fromName: ""
  # From address used in emails. This field is required if you want to enable email sending in Artifact Hub
  from: ""
  # Reply-to address used in emails
  replyTo: ""
  # SMTP server configuration
  smtp:
    # Authentication mechanism
    # Options: "login", "plain"
    auth: plain
    # SMTP host. This field is required if you want to enable email sending in Artifact Hub
    host: ""
    # SMTP port. This field is required if you want to enable email sending in Artifact Hub
    port: 587
    username: ""
    password: ""

# Credentials
creds:
  # Docker registry username
  dockerUsername: ""
  # Docker registry password
  dockerPassword: ""

# Images configuration
images:
  # Images store
  # Options: "pg"
  store: pg

# Events configuration
events:
  # Enable repository scanning errors events
  scanningErrors: false
  # Enable repository tracking errors events
  trackingErrors: false

# Database migrator configuration
dbMigrator:
  job:
    image:
      # Database migrator image repository (without the tag)
      repository: artifacthub/db-migrator
    # Optionally specify extra list of additional labels for the dbMigrator job
    extraJobLabels: {}
    # Optionally specify extra list of additional labels for the dbMigrator pod
    extraPodLabels: {}
    # Limits the lifetime of the job after it has finished execution
    ttlSecondsAfterFinished: null
    automountServiceAccountToken: true
    serviceAccountName: default
    securityContext: {}
    containerSecurityContext: {}
    resources: {}
    # If you do want to specify resources, uncomment the following
    # lines and adjust t
… 13342 more characters

Output

{
  "commonLabels": {},
  "imagePullSecrets": [],
  "imageTag": "",
  "nameOverride": "",
  "pullPolicy": "IfNotPresent",
  "nodeSelector": {},
  "tolerations": [],
  "dynamicResourceNamePrefixEnabled": false,
  "fullnameOverride": "",
  "restrictedHTTPClient": false,
  "log": {
    "level": "info",
    "pretty": false
  },
  "db": {
    "host": "",
    "port": "5432",
    "database": "hub",
    "user": "hub",
    "password": "hub",
    "sslmode": "prefer"
  },
  "email": {
    "fromName": "",
    "from": "",
    "replyTo": "",
    "smtp": {
      "auth": "plain",
      "host": "",
      "port": 587,
      "username": "",
      "password": ""
    }
  },
  "creds": {
    "dockerUsername": "",
    "dockerPassword": ""
  },
  "images": {
    "store": "pg"
  },
  "events": {
    "scanningErrors": false,
    "trackingErrors": false
  },
  "dbMigrator": {
    "job": {
      "image": {
        "repository": "artifacthub/db-migrator"
      },
      "extraJobLabels": {},
      "extraPodLabels": {},
      "ttlSecondsAfterFinished": null,
      "automountServiceAccountToken": true,
      "serviceAccountName": "default",
      "securityContext": {},
      "containerSecurityContext": {},
      "resources": {},
      "nodeSelector": {},
      "tolerations": [],
      "extraEnvVars": [],
      "extraVolumeMounts": [],
      "extraVolumes": []
    },
    "loadSampleData": true,
    "configDir": "/home/db-migrator/.cfg"
  },
  "hub": {
    "ingress": {
      "enabled": true,
      "ingressClassName": "",
      "annotations": {},
      "extraLabels": {},
      "defaultBackendEnabled": true,
      "rules": [],
      "tls": []
    },
    "service": {
      "type": "NodePort",
      "port": 80
    },
    "serviceAccount": {
      "create": true,
      "name": "",
      "automountServiceAccountToken": true
    },
    "rbac": {
      "create": true
    },
    "deploy": {
      "readinessGates": [],
      "replicaCount": 1,
      "image": {
        "repository": "artifacthub/hub"
      },
      "securityContext": {},
      "containerSecurityContext": {},
      "resources": {},
      "initContainers": {
        "checkDbMigrator": {
          "image": {
            "repository": "rancher/kubectl"
          },
          "resources": {},
          "securityContext": {}
        },
        "checkDbIsReady": {
          "resources": {},
          "securityContext": {}
        }
      },
      "extraDeploymentLabels": {},
      "extraPodLabels": {},
      "extraVolumes": [],
      "extraVolumeMounts": [],
      "nodeSelector": {},
      "tolerations": [],
      "extraContainers": [],
      "extraEnvVars": []
    },
    "server": {
      "allowPrivateRepositories": false,
      "allowUserSignUp": true,
      "cacheDir": "",
      "configDir": "/home/hub/.cfg",
      "bannersURL": "",
      "baseURL": "",
      "shutdownTimeout": "10s",
      "motd": "",
      "motdSeverity": "info",
      "basicAuth": {
        "enabled": false,
        "username": "hub",
        "password": "ch
… 3834 more characters
Automatic checks (1)
  • python: code = "import json; d = json.load(open('config.json')); assert d['hub']['service'] == {'type': 'NodePort', 'port': 80} and d['log']['level'] == 'info', d['hub'].get('service')"