Git Product home page Git Product logo

dxcfg's Introduction

dxcfg

dxcfg ci codecov deno doc

dxcfg allows you to use javascript/typescript to generate configuration in the Deno sandbox.

  • For developers it can be used a familiar and expressive frontend.
  • For operators it can be used as a backend for enforcing schema validation, security policies, resource usage policies and hermeticity: see hermeticity example.

Its an opinionated port of jkcfg API to deno and is a work in progress.

Example Usage

Let's generate a multi resource yaml file using template literals. Here we use template literals to generate a multi-resource yaml file.

index.js uses the generated kubernetes types from the dxcfg_kubernetes module.

import { Format, param, write } from "https://deno.land/x/[email protected]/mod.ts";
import { api } from "https://deno.land/x/[email protected]/mod.ts";

function resources(Values) {
  return [
    new api.apps.v1.createDeployment({
      metadata: {
        name: `${Values.name}-dep`,
      },
      spec: {
        template: {
          labels: { app: Values.app },
          spec: {
            containers: {
              hello: {
                image: `${Values.image.repository}:${Values.image.tag}`,
              },
            },
          },
        },
      },
    }),
    new api.core.v1.createService({
      metadata: {
        name: `${Values.name}-svc`,
        labels: { app: Values.app },
      },
      spec: {
        selector: {
          app: Values.app,
        },
      },
    }),
  ];
}

const defaults = {
  name: "helloworld",
  app: "hello",
  image: {
    repository: "weaveworks/helloworld",
    tag: "v1",
  },
};

const values = await param.object("values", defaults);
await write(resources(values), "chart.yaml", { format: Format.MULTI_YAML });

Run with deno:

deno run --unstable --allow-read --allow-write index.js -p values.name=demo -p values.image.tag=v2

which writes a chart.yaml:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: demo-dep
spec:
  template:
    labels:
      app: hello
    spec:
      containers:
        hello:
          image: 'weaveworks/helloworld:v2'
---
apiVersion: v1
kind: Service
metadata:
  name: demo-svc
  labels:
    app: hello
spec:
  selector:
    app: hello

See more in examples

Principles

  • Keep the API surface small and obvious.
  • Free of opinions on how configuration should be managed.
  • Don’t reproduce features from other tools: helm, kustomize, cdktf etc. rather provide integrations to call them.
  • Don’t write custom APIs for components: grafana, tekton etc. Use the official SDK or expose a generated typescript api from openapi or CRD spec .

Roadmap

  • An example complex deployment pipeline on top of GKE/GCP
  • A typescript API for an efficient buildkit builder(written in Rust)

dxcfg's People

Contributors

adnaan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.